Class: Gitlab::Ci::Badge::Pipeline::Status
- Defined in:
- lib/gitlab/ci/badge/pipeline/status.rb
Overview
Pipeline status badge
Instance Attribute Summary collapse
-
#customization ⇒ Object
readonly
Returns the value of attribute customization.
-
#project ⇒ Object
readonly
Returns the value of attribute project.
-
#ref ⇒ Object
readonly
Returns the value of attribute ref.
Instance Method Summary collapse
- #entity ⇒ Object
-
#initialize(project, ref, opts: {}) ⇒ Status
constructor
A new instance of Status.
-
#metadata ⇒ Object
rubocop: enable CodeReuse/ActiveRecord.
-
#status ⇒ Object
rubocop: disable CodeReuse/ActiveRecord.
- #template ⇒ Object
Constructor Details
#initialize(project, ref, opts: {}) ⇒ Status
Returns a new instance of Status.
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/gitlab/ci/badge/pipeline/status.rb', line 12 def initialize(project, ref, opts: {}) @project = project @ref = ref @ignore_skipped = Gitlab::Utils.to_boolean(opts[:ignore_skipped], default: false) @customization = { key_width: opts[:key_width].to_i, key_text: opts[:key_text] } @sha = @project.commit(@ref).try(:sha) end |
Instance Attribute Details
#customization ⇒ Object (readonly)
Returns the value of attribute customization.
10 11 12 |
# File 'lib/gitlab/ci/badge/pipeline/status.rb', line 10 def customization @customization end |
#project ⇒ Object (readonly)
Returns the value of attribute project.
10 11 12 |
# File 'lib/gitlab/ci/badge/pipeline/status.rb', line 10 def project @project end |
#ref ⇒ Object (readonly)
Returns the value of attribute ref.
10 11 12 |
# File 'lib/gitlab/ci/badge/pipeline/status.rb', line 10 def ref @ref end |
Instance Method Details
#entity ⇒ Object
24 25 26 |
# File 'lib/gitlab/ci/badge/pipeline/status.rb', line 24 def entity 'pipeline' end |
#metadata ⇒ Object
rubocop: enable CodeReuse/ActiveRecord
38 39 40 |
# File 'lib/gitlab/ci/badge/pipeline/status.rb', line 38 def @metadata ||= Pipeline::Metadata.new(self) end |
#status ⇒ Object
rubocop: disable CodeReuse/ActiveRecord
29 30 31 32 33 34 35 |
# File 'lib/gitlab/ci/badge/pipeline/status.rb', line 29 def status pipelines = @project.ci_pipelines .where(sha: @sha) relation = @ignore_skipped ? pipelines.without_statuses([:skipped]) : pipelines relation.latest_status(@ref) || 'unknown' end |