Class: RobotArmy::Proxy
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(messenger, hash) ⇒ Proxy
Returns a new instance of Proxy.
5
6
7
8
|
# File 'lib/robot-army/proxy.rb', line 5
def initialize(messenger, hash)
@messenger = messenger
@hash = hash
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(*args, &block) ⇒ Object
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/robot-army/proxy.rb', line 27
def method_missing(*args, &block)
@messenger.post(:status => 'proxy', :data => {:hash => @hash, :call => args})
response = @messenger.get
case response[:status]
when 'proxy'
return RobotArmy::Proxy.new(@messenger, response[:data])
else
return RobotArmy::Connection.handle_response(response)
end
end
|
Class Method Details
.generator_for(object) ⇒ Object
21
22
23
|
# File 'lib/robot-army/proxy.rb', line 21
def self.generator_for(object)
"RobotArmy::Proxy.new(RobotArmy.upstream, #{object.hash.inspect})"
end
|
Instance Method Details
#sh(binary, *args) ⇒ Object
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/robot-army/proxy.rb', line 10
def sh(binary, *args)
command = [binary, *args].join(' ')
output = %x{#{command} 2>&1}
if not $?.success?
raise RobotArmy::ShellCommandError.new(command, $?.exitstatus, output)
end
return output
end
|