class SSHKit::Coordinator

Attributes

hosts[RW]

Public Class Methods

new(raw_hosts) click to toggle source
# File lib/sshkit/coordinator.rb, line 7
def initialize(raw_hosts)
  @raw_hosts = Array(raw_hosts)
  @hosts = @raw_hosts.any? ? resolve_hosts : []
end

Public Instance Methods

each(options={}, &block) click to toggle source
# File lib/sshkit/coordinator.rb, line 12
def each(options={}, &block)
  if hosts
    options = default_options.merge(options)
    case options[:in]
    when :parallel then Runner::Parallel
    when :sequence then Runner::Sequential
    when :groups   then Runner::Group
    else
      options[:in]
    end.new(hosts, options, &block).execute
  else
    Runner::Null.new(hosts, options, &block).execute
  end
end

Private Instance Methods

default_options() click to toggle source
# File lib/sshkit/coordinator.rb, line 29
def default_options
  SSHKit.config.default_runner_config
end
resolve_hosts() click to toggle source
# File lib/sshkit/coordinator.rb, line 33
def resolve_hosts
  @raw_hosts.collect { |rh| rh.is_a?(Host) ? rh : Host.new(rh) }.uniq
end