Sha256: 6958f39763dfa53332966c197ae8006be86248d1935059c1941cae2f8c257b76

Contents?: true

Size: 883 Bytes

Versions: 11

Compression:

Stored size: 883 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
          raise RuntimeError, "Don't know how to handle run style #{options[:in].inspect}"
        end.new(hosts, options, &block).execute
      else
        Runner::Null.new(hosts, options, &block).execute
      end
    end

    private

      def default_options
        { in: :parallel }
      end

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

  end

end

Version data entries

11 entries across 9 versions & 3 rubygems

Version Path
honeybadger-2.4.0 vendor/gems/ruby/2.1.0/gems/sshkit-1.5.1/lib/sshkit/coordinator.rb
honeybadger-2.4.0 vendor/gems/ruby/2.2.0/gems/sshkit-1.5.1/lib/sshkit/coordinator.rb
honeybadger-2.4.0 vendor/gems/ruby/1.9.1/gems/sshkit-1.5.1/lib/sshkit/coordinator.rb
sshkit-1.8.1 lib/sshkit/coordinator.rb
sshkit-1.8.0 lib/sshkit/coordinator.rb
sc_core-0.0.7 test/dummy/vendor/bundle/ruby/2.2.0/gems/sshkit-1.7.1/lib/sshkit/coordinator.rb
sshkit-1.7.1 lib/sshkit/coordinator.rb
sshkit-1.7.0 lib/sshkit/coordinator.rb
sshkit-1.6.1 lib/sshkit/coordinator.rb
sshkit-1.5.1 lib/sshkit/coordinator.rb
sshkit-1.5.0 lib/sshkit/coordinator.rb