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
-
#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
Constructor Details
#initialize(command, options = {}) ⇒ Shell
Returns a new instance of Shell.
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/lsync/shell.rb', line 33 def initialize(command, = {}) case command when Array @command = command else @command = [command] end @options = end |
Instance Method Details
#connect(server) ⇒ Object
53 54 55 56 57 58 59 60 |
# File 'lib/lsync/shell.rb', line 53 def connect(server) = {:passthrough => []} if server.local? return RExec::start_server(CLIENT_CODE, ruby_command, ) else return RExec::start_server(CLIENT_CODE, connection_command(server) + ruby_command, ) end end |
#connection_command(server, arguments = []) ⇒ Object
The command required to connect to the remote machine.
49 50 51 |
# File 'lib/lsync/shell.rb', line 49 def connection_command(server, arguments = []) @command + (@options[:arguments] || []) + arguments + [server.host] end |
#ruby_command ⇒ Object
44 45 46 |
# File 'lib/lsync/shell.rb', line 44 def ruby_command @options[:ruby] || ["ruby"] end |