Class: Semaph::Model::Pipeline

Inherits:
Object
  • Object
show all
Defined in:
lib/semaph/model/pipeline.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#idObject (readonly)

Returns the value of attribute id.



8
9
10
# File 'lib/semaph/model/pipeline.rb', line 8

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



8
9
10
# File 'lib/semaph/model/pipeline.rb', line 8

def name
  @name
end

#rawObject (readonly)

Returns the value of attribute raw.



8
9
10
# File 'lib/semaph/model/pipeline.rb', line 8

def raw
  @raw
end

#resultObject (readonly)

Returns the value of attribute result.



8
9
10
# File 'lib/semaph/model/pipeline.rb', line 8

def result
  @result
end

#stateObject (readonly)

Returns the value of attribute state.



8
9
10
# File 'lib/semaph/model/pipeline.rb', line 8

def state
  @state
end

#workflowObject (readonly)

Returns the value of attribute workflow.



8
9
10
# File 'lib/semaph/model/pipeline.rb', line 8

def workflow
  @workflow
end

#yamlObject (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

#descriptionObject



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

Returns:

  • (Boolean)


44
45
46
# File 'lib/semaph/model/pipeline.rb', line 44

def done?
  @state == "DONE"
end

#iconObject



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_collectionObject



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_collectionObject



31
32
33
# File 'lib/semaph/model/pipeline.rb', line 31

def promotion_collection
  @promotion_collection ||= PromotionCollection.new(self)
end