Class: Blubber::Flow

Inherits:
Object
  • Object
show all
Defined in:
lib/blubber/flow.rb

Instance Method Summary collapse

Constructor Details

#initialize(layers:, context:, build: true, tag: true, push: true) ⇒ Flow

Returns a new instance of Flow.



7
8
9
10
11
# File 'lib/blubber/flow.rb', line 7

def initialize(layers:, context:, build: true, tag: true, push: true)
  @context = context
  @layers = detect_layers(layers: layers)
  @flow = { build: build, tag: tag, push: push }
end

Instance Method Details

#runObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/blubber/flow.rb', line 13

def run
  results = layers.map do |layer|
    status = true
    status &= layer.build if flow[:build]
    status &= layer.tag if flow[:tag] && layer.build_id
    status &= layer.push if flow[:push] && layer.build_id

    [layer, status]
  end.to_h

  table = [HighLine.color('Layer', :bold), HighLine.color('Tag', :bold)]
  table += results.map do |layer, result|
    if result
      layer.tags.map { |tag| [layer.project, tag] }
    else
      [layer.project, HighLine.color('FAILED', :red)]
    end
  end
  puts HighLine.new.list(table.flatten, :columns_across, 2)

  results.values.reduce(:&)
end