Sha256: fda0a0553b46726de8906d2b36194ebd45cf1452f5b528e4ac054dfe3cd8e192

Contents?: true

Size: 506 Bytes

Versions: 5

Compression:

Stored size: 506 Bytes

Contents

require "net/ssh"

module Yads

  class SSH

    def initialize(config)
      options = { :forward_agent => config[:forward_agent] }
      options[:port] = config[:port] if config[:port]

      @ssh = Net::SSH.start(config[:host], config[:user], options)
    end

    def execute(cmd)
      if block_given?
        @ssh.exec(cmd) do |ch, stream, data|
          yield data
        end
        @ssh.loop
      else
        @ssh.exec!(cmd)
      end
    end

    def close
      @ssh.close
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
yads-0.3.1 lib/yads/ssh.rb
yads-0.3.0.beta lib/yads/ssh.rb
yads-0.2.0 lib/yads/ssh.rb
yads-0.1.2 lib/yads/ssh.rb
yads-0.1.1 lib/yads/ssh.rb