Class: Escualo::Session::Remote

Inherits:
Escualo::Session show all
Defined in:
lib/escualo/session/remote_session.rb

Instance Attribute Summary

Attributes inherited from Escualo::Session

#options

Instance Method Summary collapse

Methods inherited from Escualo::Session

#check?, #clean_environment_variables!, parse_session_options, set_command, #set_environment_variables!, #setup_environment_variables!, #tell!, #tell_all!, #unset_environment_variables!, #upload_template!, within, within_dockerized_session, within_ssh_session, #write_template!

Constructor Details

#initialize(ssh, options) ⇒ Remote

Returns a new instance of Remote.



2
3
4
5
# File 'lib/escualo/session/remote_session.rb', line 2

def initialize(ssh, options)
  super(options)
  @ssh = ssh
end

Instance Method Details

#ask(command) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/escualo/session/remote_session.rb', line 16

def ask(command)
  out = ''
  @ssh.stream! wrap(command) do |_stream, data|
    out << data
  end
  out
end

#exec!(command) ⇒ Object



11
12
13
14
# File 'lib/escualo/session/remote_session.rb', line 11

def exec!(command)
  ask command
  nil
end

#stream!(command) ⇒ Object



24
25
26
27
28
29
30
31
32
33
# File 'lib/escualo/session/remote_session.rb', line 24

def stream!(command)
  command = wrap(command)
  @ssh.stream! command do |stream, data|
    if stream == :stdout
      $stdout.print data
    else
      $stderr.print data
    end
  end
end

#upload!(file, destination) ⇒ Object



7
8
9
# File 'lib/escualo/session/remote_session.rb', line 7

def upload!(file, destination)
  @ssh.scp.upload! file, destination
end