Class: Duoconsole::CommandServer
- Inherits:
-
Object
- Object
- Duoconsole::CommandServer
- Defined in:
- lib/duoconsole.rb
Constant Summary collapse
- RECOGNIZED_COMMANDS =
[:test, :rake]
Instance Attribute Summary collapse
-
#socket ⇒ Object
readonly
Returns the value of attribute socket.
Instance Method Summary collapse
-
#initialize(socket) ⇒ CommandServer
constructor
A new instance of CommandServer.
- #start ⇒ Object
Constructor Details
#initialize(socket) ⇒ CommandServer
Returns a new instance of CommandServer.
102 103 104 |
# File 'lib/duoconsole.rb', line 102 def initialize socket @socket = socket end |
Instance Attribute Details
#socket ⇒ Object (readonly)
Returns the value of attribute socket.
100 101 102 |
# File 'lib/duoconsole.rb', line 100 def socket @socket end |
Instance Method Details
#start ⇒ Object
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/duoconsole.rb', line 106 def start loop do msg = socket.recv(1000) command, args = Marshal.load(msg) retval = if valid_command?(command) require_app unless @app_required run_command(command, args) else "Unrecognized command. Valid commands are #{RECOGNIZED_COMMANDS.join(', ')}" end socket.write(retval) end end |