Class: Semaph::Model::Pipeline
- Inherits:
-
Object
- Object
- Semaph::Model::Pipeline
- Defined in:
- lib/semaph/model/pipeline.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
-
#workflow ⇒ Object
readonly
Returns the value of attribute workflow.
-
#yaml ⇒ Object
readonly
Returns the value of attribute yaml.
Instance Method Summary collapse
- #description ⇒ Object
- #done? ⇒ Boolean
- #icon ⇒ Object
-
#initialize(workflow, raw) ⇒ Pipeline
constructor
A new instance of Pipeline.
- #job_collection ⇒ Object
- #promote(name) ⇒ Object
- #promotion_collection ⇒ Object
Constructor Details
#initialize(workflow, raw) ⇒ Pipeline
Returns a new instance of Pipeline.
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/semaph/model/pipeline.rb', line 10 def initialize(workflow, raw) @workflow = workflow @raw = raw @id = raw["ppl_id"] @yaml = raw["yaml_file_name"] @name = raw["name"] @state = raw["state"] @result = raw["result"] %w[created done pending queuing running stopping].each do |name| extract_time(name) end end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
8 9 10 |
# File 'lib/semaph/model/pipeline.rb', line 8 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/semaph/model/pipeline.rb', line 8 def name @name end |
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
8 9 10 |
# File 'lib/semaph/model/pipeline.rb', line 8 def raw @raw end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
8 9 10 |
# File 'lib/semaph/model/pipeline.rb', line 8 def result @result end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
8 9 10 |
# File 'lib/semaph/model/pipeline.rb', line 8 def state @state end |
#workflow ⇒ Object (readonly)
Returns the value of attribute workflow.
8 9 10 |
# File 'lib/semaph/model/pipeline.rb', line 8 def workflow @workflow end |
#yaml ⇒ Object (readonly)
Returns the value of attribute yaml.
8 9 10 |
# File 'lib/semaph/model/pipeline.rb', line 8 def yaml @yaml end |
Instance Method Details
#description ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/semaph/model/pipeline.rb', line 35 def description [ icon, time, name, "(#{yaml})", ].compact.join(" ") end |
#done? ⇒ Boolean
44 45 46 |
# File 'lib/semaph/model/pipeline.rb', line 44 def done? @state == "DONE" end |
#icon ⇒ Object
48 49 50 51 52 53 54 55 56 |
# File 'lib/semaph/model/pipeline.rb', line 48 def icon return "🔵" unless done? return "⛔" if @result == "STOPPED" return "🟢" if @result == "PASSED" "🔴" end |
#job_collection ⇒ Object
27 28 29 |
# File 'lib/semaph/model/pipeline.rb', line 27 def job_collection @job_collection ||= JobCollection.new(self) end |
#promote(name) ⇒ Object
23 24 25 |
# File 'lib/semaph/model/pipeline.rb', line 23 def promote(name) workflow.project.client.promote(id, name) end |
#promotion_collection ⇒ Object
31 32 33 |
# File 'lib/semaph/model/pipeline.rb', line 31 def promotion_collection @promotion_collection ||= PromotionCollection.new(self) end |