Sha256: a4043c2d969b40c4ccc90eb39c9b1cc9ddedb172030adca9ab25cbd48738ae10

Contents?: true

Size: 822 Bytes

Versions: 9

Compression:

Stored size: 822 Bytes

Contents

module SSHKit

  class Coordinator

    attr_accessor :hosts

    def initialize(raw_hosts)
      @raw_hosts = Array(raw_hosts)
      @hosts = @raw_hosts.any? ? resolve_hosts : []
    end

    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

    def default_options
      { in: SSHKit.config.default_runner }
    end

    def resolve_hosts
      @raw_hosts.collect { |rh| rh.is_a?(Host) ? rh : Host.new(rh) }.uniq
    end

  end

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
sshkit-1.11.5 lib/sshkit/coordinator.rb
sshkit-1.11.4 lib/sshkit/coordinator.rb
sshkit-1.11.3 lib/sshkit/coordinator.rb
sshkit-1.11.2 lib/sshkit/coordinator.rb
sshkit-1.11.1 lib/sshkit/coordinator.rb
sshkit-1.11.0 lib/sshkit/coordinator.rb
sshkit-1.10.0 lib/sshkit/coordinator.rb
sshkit-1.9.0 lib/sshkit/coordinator.rb
sshkit-1.9.0.rc1 lib/sshkit/coordinator.rb