Class: Dizby::SpawnCommand
- Inherits:
-
Object
- Object
- Dizby::SpawnCommand
- Defined in:
- lib/dizby/tunnel/spawn_command.rb
Constant Summary collapse
- TEMPLATE =
"require'dizby/tunnel/spawned';Dizby::Spawned.%s('%s',%s){%s}".freeze
Instance Attribute Summary collapse
-
#config
Returns the value of attribute config.
-
#ruby_cmd
Returns the value of attribute ruby_cmd.
-
#uri
Returns the value of attribute uri.
Class Method Summary collapse
- .local_file(file)
-
.remote_file(file, obj_name)
WARNING: Dangerous operation.
- .text(script)
Instance Method Summary collapse
- #dynamic? ⇒ Boolean
-
#initialize(data, config = {}) ⇒ SpawnCommand
constructor
A new instance of SpawnCommand.
- #set_dynamic_mode
- #to_cmd (also: #to_s)
Constructor Details
#initialize(data, config = {}) ⇒ SpawnCommand
15 16 17 18 19 20 21 |
# File 'lib/dizby/tunnel/spawn_command.rb', line 15 def initialize(data, config = {}) @data = data @ruby_cmd = 'ruby' @uri = 'drb://' @config = config @mode = :static end |
Instance Attribute Details
#config
Returns the value of attribute config.
31 32 33 |
# File 'lib/dizby/tunnel/spawn_command.rb', line 31 def config @config end |
#ruby_cmd
Returns the value of attribute ruby_cmd.
31 32 33 |
# File 'lib/dizby/tunnel/spawn_command.rb', line 31 def ruby_cmd @ruby_cmd end |
#uri
Returns the value of attribute uri.
31 32 33 |
# File 'lib/dizby/tunnel/spawn_command.rb', line 31 def uri @uri end |
Class Method Details
.local_file(file)
45 46 47 |
# File 'lib/dizby/tunnel/spawn_command.rb', line 45 def local_file(file) new(File.read(file)) end |
.remote_file(file, obj_name)
WARNING: Dangerous operation. This loads an object from a file on the remote machine. That file may be insecure or modified without notice.
51 52 53 |
# File 'lib/dizby/tunnel/spawn_command.rb', line 51 def remote_file(file, obj_name) new("load '#{file}'; #{obj_name}") end |
.text(script)
41 42 43 |
# File 'lib/dizby/tunnel/spawn_command.rb', line 41 def text(script) new(script) end |
Instance Method Details
#dynamic? ⇒ Boolean
27 28 29 |
# File 'lib/dizby/tunnel/spawn_command.rb', line 27 def dynamic? @mode == :dynamic end |
#set_dynamic_mode
23 24 25 |
# File 'lib/dizby/tunnel/spawn_command.rb', line 23 def set_dynamic_mode @mode = :dynamic end |
#to_cmd Also known as: to_s
33 34 35 36 37 |
# File 'lib/dizby/tunnel/spawn_command.rb', line 33 def to_cmd # TODO: needs a lot of work... args = [@mode, @uri.shellescape, @config.inspect, @data.shellescape] [@ruby_cmd, '-e', %("#{TEMPLATE % args}")].join ' ' end |