Class: SSHKit::Coordinator

Inherits:
Object
  • Object
show all
Defined in:
lib/sshkit/coordinator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw_hosts) ⇒ Coordinator

Returns a new instance of Coordinator.

Raises:

  • (NoValidHosts)


7
8
9
10
11
# File 'lib/sshkit/coordinator.rb', line 7

def initialize(raw_hosts)
  @raw_hosts = Array(raw_hosts)
  raise NoValidHosts unless Array(raw_hosts).any?
  resolve_hosts!
end

Instance Attribute Details

#hostsObject

Returns the value of attribute hosts.



5
6
7
# File 'lib/sshkit/coordinator.rb', line 5

def hosts
  @hosts
end

Instance Method Details

#each(options = {}, &block) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/sshkit/coordinator.rb', line 13

def each(options={}, &block)
  options = default_options.merge(options)
  case options[:in]
  when :parallel then Runner::Parallel
  when :sequence then Runner::Sequential
  when :groups   then Runner::Group
  else
    raise RuntimeError, "Don't know how to handle run style #{options[:in].inspect}"
  end.new(hosts, &block).execute
end