Class: LSync::Shell
- Inherits:
-
Object
- Object
- LSync::Shell
- Defined in:
- lib/lsync/shell.rb
Overview
A shell provides access to a server, typically to run an instance of ‘ruby`.
Direct Known Subclasses
Instance Method Summary collapse
-
#connect(server) ⇒ Object
Establish a connection to the server using this shell configuration.
-
#connection_command(server, arguments = []) ⇒ Object
The command required to connect to the remote machine.
-
#initialize(command, options = {}) ⇒ Shell
constructor
A new instance of Shell.
-
#ruby_command ⇒ Object
The command required to start an instance of Ruby.
Constructor Details
#initialize(command, options = {}) ⇒ Shell
Returns a new instance of Shell.
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/lsync/shell.rb', line 14 def initialize(command, = {}) case command when Array @command = command else @command = [command] end = end |
Instance Method Details
#connect(server) ⇒ Object
Establish a connection to the server using this shell configuration.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/lsync/shell.rb', line 36 def connect(server) begin connection, pid = open_connection(server) = connection.receive_object ensure connection.dump_errors if connection end if != :ready raise ConnectionError.new("Remote shell connection was not successful: #{message}") end return connection, pid end |
#connection_command(server, arguments = []) ⇒ Object
The command required to connect to the remote machine.
31 32 33 |
# File 'lib/lsync/shell.rb', line 31 def connection_command(server, arguments = []) @command + ([:arguments] || []) + arguments + [server.host] end |
#ruby_command ⇒ Object
The command required to start an instance of Ruby.
26 27 28 |
# File 'lib/lsync/shell.rb', line 26 def ruby_command [:ruby] || ["ruby"] end |