Class: Cult::CommanderSync
- Inherits:
-
Object
- Object
- Cult::CommanderSync
- Defined in:
- lib/cult/commander_sync.rb
Instance Attribute Summary collapse
-
#nodes ⇒ Object
readonly
Returns the value of attribute nodes.
-
#project ⇒ Object
readonly
Returns the value of attribute project.
Instance Method Summary collapse
-
#initialize(project:, nodes:) ⇒ CommanderSync
constructor
A new instance of CommanderSync.
- #required_passes(roles) ⇒ Object
- #sync!(roles: nil, passes: nil) ⇒ Object
Constructor Details
#initialize(project:, nodes:) ⇒ CommanderSync
Returns a new instance of CommanderSync.
4 5 6 |
# File 'lib/cult/commander_sync.rb', line 4 def initialize(project:, nodes:) @project, @nodes = project, nodes end |
Instance Attribute Details
#nodes ⇒ Object (readonly)
Returns the value of attribute nodes.
3 4 5 |
# File 'lib/cult/commander_sync.rb', line 3 def nodes @nodes end |
#project ⇒ Object (readonly)
Returns the value of attribute project.
3 4 5 |
# File 'lib/cult/commander_sync.rb', line 3 def project @project end |
Instance Method Details
#required_passes(roles) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/cult/commander_sync.rb', line 21 def required_passes(roles) # searches through every node and extracts which passes have to be ran # to satisfy every event task nodes.map(&:build_order).flatten.uniq .select { |r| roles.nil? ? true : roles.include?(r) } .map(&:event_tasks).flatten.map(&:pass).uniq.sort end |
#sync!(roles: nil, passes: nil) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/cult/commander_sync.rb', line 8 def sync!(roles: nil, passes: nil) roles ||= Cult.project.roles passes ||= required_passes(roles) passes.each do |pass| puts Rainbow("Executing pass #{pass}").yellow Cult.paramap(nodes) do |node| c = Commander.new(project: project, node: node) c.sync!(pass: pass, roles: roles) end end end |