debian-mirror-gitlab/lib/gitlab/badge/metadata.rb

43 lines
803 B
Ruby
Raw Normal View History

2018-12-13 13:39:08 +05:30
# frozen_string_literal: true
2016-09-13 17:45:13 +05:30
module Gitlab
module Badge
##
# Abstract class for badge metadata
#
class Metadata
2017-09-10 17:25:29 +05:30
include Gitlab::Routing
2016-09-13 17:45:13 +05:30
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
2017-08-17 22:00:37 +05:30
def to_asciidoc
"image:#{image_url}[link=\"#{link_url}\",title=\"#{title}\"]"
end
2016-09-13 17:45:13 +05:30
def title
raise NotImplementedError
end
def image_url
raise NotImplementedError
end
def link_url
raise NotImplementedError
end
end
end
end