Class: GCI::Pipeline
- Inherits:
-
Object
- Object
- GCI::Pipeline
- Defined in:
- lib/gci/pipeline.rb
Instance Attribute Summary collapse
-
#gitlab_ci_file ⇒ Object
writeonly
Sets the attribute gitlab_ci_file.
-
#image ⇒ Object
Returns the value of attribute image.
-
#jobs ⇒ Object
readonly
Returns the value of attribute jobs.
-
#stages ⇒ Object
Returns the value of attribute stages.
-
#variables ⇒ Object
Returns the value of attribute variables.
-
#workflow ⇒ Object
Returns the value of attribute workflow.
Instance Method Summary collapse
-
#initialize {|_self| ... } ⇒ Pipeline
constructor
A new instance of Pipeline.
- #to_h ⇒ Object
- #to_yaml ⇒ Object
- #write ⇒ Object
Constructor Details
#initialize {|_self| ... } ⇒ Pipeline
Returns a new instance of Pipeline.
9 10 11 12 13 14 15 |
# File 'lib/gci/pipeline.rb', line 9 def initialize @jobs = Job::Collection.new @stages = i[build test deploy] @gitlab_ci_file = 'child.gitlab-ci.yml' yield(self) if block_given? end |
Instance Attribute Details
#gitlab_ci_file=(value) ⇒ Object (writeonly)
Sets the attribute gitlab_ci_file
7 8 9 |
# File 'lib/gci/pipeline.rb', line 7 def gitlab_ci_file=(value) @gitlab_ci_file = value end |
#image ⇒ Object
Returns the value of attribute image.
6 7 8 |
# File 'lib/gci/pipeline.rb', line 6 def image @image end |
#jobs ⇒ Object (readonly)
Returns the value of attribute jobs.
5 6 7 |
# File 'lib/gci/pipeline.rb', line 5 def jobs @jobs end |
#stages ⇒ Object
Returns the value of attribute stages.
6 7 8 |
# File 'lib/gci/pipeline.rb', line 6 def stages @stages end |
#variables ⇒ Object
Returns the value of attribute variables.
6 7 8 |
# File 'lib/gci/pipeline.rb', line 6 def variables @variables end |
#workflow ⇒ Object
Returns the value of attribute workflow.
6 7 8 |
# File 'lib/gci/pipeline.rb', line 6 def workflow @workflow end |
Instance Method Details
#to_h ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/gci/pipeline.rb', line 23 def to_h data = {} data.merge!(stages: stages.map(&:to_s)) data.merge!(image: @image) if @image.present? data.merge!(workflow: @workflow) if @workflow.present? data.merge!(@jobs.to_h) data end |
#to_yaml ⇒ Object
32 33 34 |
# File 'lib/gci/pipeline.rb', line 32 def to_yaml to_h.to_yaml end |
#write ⇒ Object
17 18 19 20 21 |
# File 'lib/gci/pipeline.rb', line 17 def write File.open(@gitlab_ci_file, 'wb') do |file| file.write(to_yaml) end end |