Module: Messed::Tasks::Console::KeyboardHandler
- Includes:
- EM::Protocols::LineText2
- Defined in:
- lib/messed/tasks/console.rb
Instance Attribute Summary collapse
-
#environment ⇒ Object
Returns the value of attribute environment.
-
#root ⇒ Object
Returns the value of attribute root.
Instance Method Summary collapse
- #log_outgoing(responses) ⇒ Object
- #post_init ⇒ Object
- #print_banner ⇒ Object
- #prompt ⇒ Object
- #receive_line(data) ⇒ Object
Instance Attribute Details
#environment ⇒ Object
Returns the value of attribute environment.
8 9 10 |
# File 'lib/messed/tasks/console.rb', line 8 def environment @environment end |
#root ⇒ Object
Returns the value of attribute root.
8 9 10 |
# File 'lib/messed/tasks/console.rb', line 8 def root @root end |
Instance Method Details
#log_outgoing(responses) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/messed/tasks/console.rb', line 10 def log_outgoing(responses) if responses.empty? puts "No responses" else puts "Responding ... #{responses.map{|r| "`#{r.body}'"}.join(', ')}" end end |
#post_init ⇒ Object
23 24 25 26 |
# File 'lib/messed/tasks/console.rb', line 23 def post_init prompt end |
#print_banner ⇒ Object
28 29 30 31 32 |
# File 'lib/messed/tasks/console.rb', line 28 def puts "? help" puts "!q quit" puts "Eventhing else is a message" end |
#prompt ⇒ Object
18 19 20 21 |
# File 'lib/messed/tasks/console.rb', line 18 def prompt $stdout << ">> " $stdout.flush end |
#receive_line(data) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/messed/tasks/console.rb', line 34 def receive_line(data) case data.strip when '!q' EM.stop_event_loop exit when '?' else pid = EM.fork_reactor do Booter.new(root, :environment => environment, :supress_banner => true) do |booter| Messed::Logger.instance.setup_logger(::Logger.new(STDOUT), :debug) log_outgoing(booter.application.process(booter.application..new(data.strip))) EM.stop_event_loop end end Process.wait(pid) end prompt end |