BigW Consortium Gitlab

status.rb 706 Bytes
Newer Older
1 2
module Gitlab
  module Badge
3
    module Pipeline
4
      ##
5
      # Pipeline status badge
6 7
      #
      class Status < Badge::Base
8
        attr_reader :project, :ref
9 10 11 12

        def initialize(project, ref)
          @project = project
          @ref = ref
13

14 15 16
          @sha = @project.commit(@ref).try(:sha)
        end

17
        def entity
18
          'pipeline'
19 20
        end

21 22
        def status
          @project.pipelines
23
            .where(sha: @sha)
24
            .latest_status(@ref) || 'unknown'
25 26 27
        end

        def metadata
28
          @metadata ||= Pipeline::Metadata.new(self)
29 30 31
        end

        def template
32
          @template ||= Pipeline::Template.new(self)
33 34 35 36 37
        end
      end
    end
  end
end