Class: Gitlab::Ci::Config::Stages

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/ci/config/stages.rb

Constant Summary collapse

EDGE_PRE =
'.pre'
EDGE_POST =
'.post'
EDGES =
[EDGE_PRE, EDGE_POST].freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Stages

Returns a new instance of Stages.



19
20
21
22
# File 'lib/gitlab/ci/config/stages.rb', line 19

def initialize(config)
  @config = config.to_h.deep_dup
  @stages = extract_stages
end

Class Method Details

.wrap_with_edge_stages(stages) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/gitlab/ci/config/stages.rb', line 11

def self.wrap_with_edge_stages(stages)
  stages = stages.to_a - EDGES
  stages.unshift EDGE_PRE
  stages.push EDGE_POST

  stages
end

Instance Method Details

#inject_edge_stages!Object



24
25
26
27
28
29
# File 'lib/gitlab/ci/config/stages.rb', line 24

def inject_edge_stages!
  return config if stages.empty?

  config[:stages] = wrap_with_edge_stages(stages)
  config
end