Sha256: ac6d8bf70c9c389141ed7a192dcd547851041031876f49c9fc2ba148d7845c50

Contents?: true

Size: 791 Bytes

Versions: 1

Compression:

Stored size: 791 Bytes

Contents

require 'shellwords'

module Remoter
  class Session
    attr_reader :remoter
    attr_reader :target
    
    def initialize(_remoter, _target)
      @remoter = _remoter
      @target = _target
    end

    def scp(from, to)
      target_cmd = "scp -o StrictHostKeyChecking=no \"#{from}\" \"#{user_part}#{target.addr}:#{to.shellescape}\""
      raise SCPError, "The following command failed: #{target_cmd}" unless system(target_cmd)
    end
    
    def exe(cmd)
      target_cmd = "ssh #{user_part}#{target.addr} -o StrictHostKeyChecking=no \"#{cmd}\""
      raise EXEError, "The following command failed: #{target_cmd}" unless system(target_cmd)
    end
    
  private
  
    def user_part
      remoter.options['username'] ? "#{remoter.options['username']}@" : ''
    end
    
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
remoter-1.0.0.pre1 lib/remoter/session.rb