debian-mirror-gitlab/lib/gitlab/badge/pipeline/status.rb

38 lines
706 B
Ruby
Raw Normal View History

2016-09-13 17:45:13 +05:30
module Gitlab
module Badge
2017-09-10 17:25:29 +05:30
module Pipeline
2016-09-13 17:45:13 +05:30
##
2017-09-10 17:25:29 +05:30
# Pipeline status badge
2016-09-13 17:45:13 +05:30
#
class Status < Badge::Base
attr_reader :project, :ref
def initialize(project, ref)
@project = project
@ref = ref
@sha = @project.commit(@ref).try(:sha)
end
def entity
2017-09-10 17:25:29 +05:30
'pipeline'
2016-09-13 17:45:13 +05:30
end
def status
@project.pipelines
2017-08-17 22:00:37 +05:30
.where(sha: @sha)
.latest_status(@ref) || 'unknown'
2016-09-13 17:45:13 +05:30
end
def metadata
2017-09-10 17:25:29 +05:30
@metadata ||= Pipeline::Metadata.new(self)
2016-09-13 17:45:13 +05:30
end
def template
2017-09-10 17:25:29 +05:30
@template ||= Pipeline::Template.new(self)
2016-09-13 17:45:13 +05:30
end
end
end
end
end