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

42 lines
792 B
Ruby
Raw Normal View History

2018-12-13 13:39:08 +05:30
# frozen_string_literal: true
2021-03-11 19:13:27 +05:30
module Gitlab::Ci
2016-09-13 17:45:13 +05:30
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
def initialize(badge)
@badge = badge
end
def to_html
2022-01-26 12:08:38 +05:30
ApplicationController.helpers.link_to(image_tag(image_url, alt: title), link_url)
2016-09-13 17:45:13 +05:30
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