gitlab-org--gitlab-foss/lib/gitlab/badge/metadata.rb
Jan Christophersen 95ed01749e Add AsciiDoc snippet for CI/CD Badges
This commit adds CI/CD Badges Snippets for AsciiDoc as requested in #26087.
I've however run into an issue in highlighting the snippet, it seems as if AsciiDoc is currently not being highlighted properly (displayed as plaintext)

Add testcase for to_asciidoc

Update test case for Badges list
2017-02-20 16:37:44 +01:00

40 lines
795 B
Ruby

module Gitlab
module Badge
##
# Abstract class for badge metadata
#
class Metadata
include Gitlab::Application.routes.url_helpers
include ActionView::Helpers::AssetTagHelper
include ActionView::Helpers::UrlHelper
def initialize(badge)
@badge = badge
end
def to_html
link_to(image_tag(image_url, alt: title), link_url)
end
def to_markdown
"[![#{title}](#{image_url})](#{link_url})"
end
def to_asciidoc
"image:#{image_url}[link=\"#{link_url}\",title=\"#{title}\"]"
end
def title
raise NotImplementedError
end
def image_url
raise NotImplementedError
end
def link_url
raise NotImplementedError
end
end
end
end