Class: Tomo::Remote

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
TaskAPI, Testing::RemoteExtensions
Defined in:
lib/tomo/remote.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ssh, context, helper_modules) ⇒ Remote

Returns a new instance of Remote.



16
17
18
19
20
21
22
23
# File 'lib/tomo/remote.rb', line 16

def initialize(ssh, context, helper_modules)
  @ssh = ssh
  @context = context
  @release = {}
  @shell_builder = ShellBuilder.new
  helper_modules.each { |mod| extend(mod) }
  freeze
end

Instance Attribute Details

#releaseObject (readonly)

Returns the value of attribute release.



14
15
16
# File 'lib/tomo/remote.rb', line 14

def release
  @release
end

Instance Method Details

#attach(*command, default_chdir: nil, **command_opts) ⇒ Object



25
26
27
28
# File 'lib/tomo/remote.rb', line 25

def attach(*command, default_chdir: nil, **command_opts)
  full_command = shell_builder.build(*command, default_chdir:)
  ssh.ssh_exec(Script.new(full_command, pty: true, **command_opts))
end

#run(*command, attach: false, default_chdir: nil, **command_opts) ⇒ Object



30
31
32
33
34
35
# File 'lib/tomo/remote.rb', line 30

def run(*command, attach: false, default_chdir: nil, **command_opts)
  attach(*command, default_chdir:, **command_opts) if attach

  full_command = shell_builder.build(*command, default_chdir:)
  ssh.ssh_subprocess(Script.new(full_command, **command_opts))
end