Class: Performa::Environment
- Inherits:
-
Object
- Object
- Performa::Environment
- Defined in:
- lib/performa/environment.rb
Instance Attribute Summary collapse
-
#hash ⇒ Object
readonly
Returns the value of attribute hash.
-
#image ⇒ Object
readonly
Returns the value of attribute image.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#stage ⇒ Object
readonly
Returns the value of attribute stage.
-
#volumes ⇒ Object
readonly
Returns the value of attribute volumes.
Class Method Summary collapse
Instance Method Summary collapse
- #assign_name ⇒ Object
-
#initialize(image:, stage: nil, volumes: nil) ⇒ Environment
constructor
A new instance of Environment.
Constructor Details
#initialize(image:, stage: nil, volumes: nil) ⇒ Environment
Returns a new instance of Environment.
30 31 32 33 34 35 |
# File 'lib/performa/environment.rb', line 30 def initialize(image:, stage: nil, volumes: nil) @image = image @stage = stage @volumes = volumes || [] assign_name end |
Instance Attribute Details
#hash ⇒ Object (readonly)
Returns the value of attribute hash.
28 29 30 |
# File 'lib/performa/environment.rb', line 28 def hash @hash end |
#image ⇒ Object (readonly)
Returns the value of attribute image.
28 29 30 |
# File 'lib/performa/environment.rb', line 28 def image @image end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
28 29 30 |
# File 'lib/performa/environment.rb', line 28 def name @name end |
#stage ⇒ Object (readonly)
Returns the value of attribute stage.
28 29 30 |
# File 'lib/performa/environment.rb', line 28 def stage @stage end |
#volumes ⇒ Object (readonly)
Returns the value of attribute volumes.
28 29 30 |
# File 'lib/performa/environment.rb', line 28 def volumes @volumes end |
Class Method Details
.all(config) ⇒ Object
7 8 9 |
# File 'lib/performa/environment.rb', line 7 def self.all(config) config["stages"] ? all_with_active_stages(config) : all_without_stages(config) end |
.all_with_active_stages(config) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/performa/environment.rb', line 17 def self.all_with_active_stages(config) skipped = config["skip"]&.flat_map { |image, stages_names| [image].product(stages_names) } config["images"].product(config["stages"].to_a).map do |image, config_stage| next if skipped&.include?([image, config_stage[0]]) stage = Stage.from_config(config_stage, image: image) new(image: image, stage: stage, volumes: config["volumes"]) end.compact end |
.all_without_stages(config) ⇒ Object
11 12 13 14 15 |
# File 'lib/performa/environment.rb', line 11 def self.all_without_stages(config) config["images"].map do |image| new(image: image, volumes: config["volumes"]) end end |
Instance Method Details
#assign_name ⇒ Object
37 38 39 |
# File 'lib/performa/environment.rb', line 37 def assign_name @name = @image.tr(":", "_") + ("-#{@stage.name}" if @stage).to_s end |