Welcome to mirror list, hosted at ThFree Co, Russian Federation.

metadata.rb « badge « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b9ae68134b0466fc05198ad8966ce63710ec9dc1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# frozen_string_literal: true

module Gitlab
  module Badge
    ##
    # Abstract class for badge metadata
    #
    class Metadata
      include Gitlab::Routing
      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