Class: RemoteRuby::StdinProcessAdapter

Inherits:
ConnectionAdapter show all
Includes:
Open3
Defined in:
lib/remote_ruby/connection_adapter/stdin_process_adapter.rb

Overview

Base class for adapters which launch an external process to execute Ruby code and send the code to its standard input.

Direct Known Subclasses

LocalStdinAdapter, SSHStdinAdapter

Instance Method Summary collapse

Methods inherited from ConnectionAdapter

#connection_name, #initialize

Constructor Details

This class inherits a constructor from RemoteRuby::ConnectionAdapter

Instance Method Details

#open(code) ⇒ Object


9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/remote_ruby/connection_adapter/stdin_process_adapter.rb', line 9

def open(code)
  result = nil

  popen3(command) do |stdin, stdout, stderr, wait_thr|
    stdin.write(code)
    stdin.close

    yield stdout, stderr

    result = wait_thr.value
  end

  return if result.success?

  raise "Remote connection exited with code #{result}"
end