Class: SSHKit::ConnectionManager

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw_hosts) ⇒ ConnectionManager

Returns a new instance of ConnectionManager.

Raises:



62
63
64
65
66
# File 'lib/sshkit/connection_manager.rb', line 62

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.



60
61
62
# File 'lib/sshkit/connection_manager.rb', line 60

def hosts
  @hosts
end

Instance Method Details

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



68
69
70
71
72
73
74
75
76
77
# File 'lib/sshkit/connection_manager.rb', line 68

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