Class: Gitlab::Ci::Config::Normalizer::NumberStrategy
- Inherits:
-
Object
- Object
- Gitlab::Ci::Config::Normalizer::NumberStrategy
- Defined in:
- lib/gitlab/ci/config/normalizer/number_strategy.rb
Class Method Summary collapse
Instance Method Summary collapse
- #attributes ⇒ Object
-
#initialize(job_name, instance, total) ⇒ NumberStrategy
constructor
A new instance of NumberStrategy.
- #name ⇒ Object
Constructor Details
#initialize(job_name, instance, total) ⇒ NumberStrategy
Returns a new instance of NumberStrategy.
22 23 24 25 26 |
# File 'lib/gitlab/ci/config/normalizer/number_strategy.rb', line 22 def initialize(job_name, instance, total) @job_name = job_name @instance = instance @total = total end |
Class Method Details
.applies_to?(config) ⇒ Boolean
9 10 11 |
# File 'lib/gitlab/ci/config/normalizer/number_strategy.rb', line 9 def applies_to?(config) config.is_a?(Integer) || config.is_a?(Hash) && config.key?(:number) end |
.build_from(job_name, config) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/gitlab/ci/config/normalizer/number_strategy.rb', line 13 def build_from(job_name, config) total = config.is_a?(Hash) ? config[:number] : config Array.new(total) do |index| new(job_name, index.next, total) end end |
Instance Method Details
#attributes ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/gitlab/ci/config/normalizer/number_strategy.rb', line 28 def attributes { name: name, instance: instance, parallel: { total: total } } end |
#name ⇒ Object
36 37 38 |
# File 'lib/gitlab/ci/config/normalizer/number_strategy.rb', line 36 def name "#{job_name} #{instance}/#{total}" end |