Class: RobotArmy::Officer
Instance Attribute Summary
Attributes inherited from Soldier
#messenger
Instance Method Summary
collapse
Methods inherited from Soldier
#initialize, #listen
Instance Method Details
#ask_for_password(user) ⇒ Object
31
32
33
34
|
# File 'lib/robot-army/officer.rb', line 31
def ask_for_password(user)
messenger.post(:status => 'password', :data => {:as => user, :user => ENV['USER']})
RobotArmy::Connection.handle_response messenger.get
end
|
#run(command, data) ⇒ Object
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/robot-army/officer.rb', line 2
def run(command, data)
case command
when :eval
debug "officer delegating eval command for user=#{data[:user].inspect}"
RobotArmy::Connection.localhost(data[:user], proc{ ask_for_password(data[:user]) }) do |local|
local.post(:command => command, :data => data)
loop do
response = local.get
case response[:status]
when 'proxy'
messenger.post(response)
local.post(messenger.get)
else
return RobotArmy::Connection.handle_response(response)
end
end
end
when :exit
super
else
super
end
end
|