summaryrefslogtreecommitdiff
path: root/lib/gitlab/badge/build.rb
blob: 28a2391dbf82e76a2fef84c9acbf3a6f54992c68 (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
module Gitlab
  module Badge
    ##
    # Build badge
    #
    class Build
      def initialize(project, ref)
        @image = ::Ci::ImageForBuildService.new.execute(project, ref: ref)
      end

      def to_s
        @image[:name].sub(/\.svg$/, '')
      end

      def type
        'image/svg+xml'
      end

      def data
        File.read(@image[:path])
      end
    end
  end
end