Class: CFTools::Watch
- Inherits:
-
CF::App::Base
- Object
- CF::App::Base
- CFTools::Watch
- Defined in:
- lib/tools-cf-plugin/watch.rb
Constant Summary collapse
- REPLY_PREFIX =
"`- reply to "
- COLUMN_WIDTH =
30
Instance Method Summary collapse
-
#color? ⇒ Boolean
colorize if told to; don’t check if output is tty.
- #precondition ⇒ Object
- #watch ⇒ Object
Instance Method Details
permalink #color? ⇒ Boolean
colorize if told to; don’t check if output is tty
11 12 13 |
# File 'lib/tools-cf-plugin/watch.rb', line 11 def color? input[:color] end |
permalink #precondition ⇒ Object
[View source]
8 |
# File 'lib/tools-cf-plugin/watch.rb', line 8 def precondition; end |
permalink #watch ⇒ Object
[View source]
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/tools-cf-plugin/watch.rb', line 34 def watch app = get_app(input[:app]) host = input[:host] port = input[:port] user = input[:user] pass = input[:password] subjects = input[:subjects] || [">"] @requests = {} @seen_apps = {} @request_ticker = 0 $stdout.sync = true watching_nats( :uri => "nats://#{user}:#{pass}@#{host}:#{port}", :logs => input[:logs], :subjects => subjects) do |msg, reply, sub, time| begin time ||= Time.now.strftime("%r") if @requests.include?(sub) process_response(sub, reply, msg, app, time) elsif !app || msg.include?(app.guid) (sub, reply, msg, app, time) end rescue => e line c("couldn't deal w/ #{sub} '#{msg}': #{e.class}: #{e}", :error) end end end |