Class: Eve::Message
- Inherits:
-
Object
- Object
- Eve::Message
- Defined in:
- lib/eve/message.rb
Instance Attribute Summary collapse
-
#app ⇒ Object
Returns the value of attribute app.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(app) ⇒ Message
constructor
A new instance of Message.
- #print_app_interrupted(id) ⇒ Object
- #print_appid(appid) ⇒ Object
- #print_cmd_error(cmd, e = nil) ⇒ Object
- #print_error(msg, error) ⇒ Object
- #print_event_mode(where) ⇒ Object
- #print_exit ⇒ Object
- #print_exported_commands(filename) ⇒ Object
- #print_help(cmds, handler = nil) ⇒ Object
- #print_importing_commands(filename) ⇒ Object
- #print_importing_complete(filename, count) ⇒ Object
- #print_poll_details(in_secs, cmds) ⇒ Object
- #print_poll_mode(id, in_secs) ⇒ Object
- #print_process_id(id) ⇒ Object
- #print_registry(registries) ⇒ Object
- #print_registry_path(paths) ⇒ Object
- #print_registry_reloaded ⇒ Object
- #print_ruby_call(call, answer) ⇒ Object
- #print_server_init ⇒ Object
- #print_shell_mode ⇒ Object
- #print_sleep(in_secs) ⇒ Object
- #print_system_call(cmd) ⇒ Object
- #print_unknown_cmd(cmd) ⇒ Object
- #print_unknown_handler(name) ⇒ Object
- #print_version(appid, show_multiple_times = true) ⇒ Object
Constructor Details
#initialize(app) ⇒ Message
Returns a new instance of Message.
7 8 9 |
# File 'lib/eve/message.rb', line 7 def initialize(app) @app = app end |
Instance Attribute Details
#app ⇒ Object
Returns the value of attribute app.
5 6 7 |
# File 'lib/eve/message.rb', line 5 def app @app end |
Class Method Details
.friendly_duration(in_secs) ⇒ Object
157 158 159 160 161 |
# File 'lib/eve/message.rb', line 157 def self.friendly_duration(in_secs) friendly = WatchMe::Timer.calculate_duration_to_s(in_secs) in_secs_to_s = "#{in_secs} seconds" output = friendly == in_secs_to_s ? friendly : "#{friendly} (#{in_secs} seconds)" end |
.friendly_now(time = nil) ⇒ Object
152 153 154 155 |
# File 'lib/eve/message.rb', line 152 def self.friendly_now(time = nil) time = Time.now if time.nil? time.strftime("%Y-%m-%d %H:%M:%S") end |
Instance Method Details
#print_app_interrupted(id) ⇒ Object
70 71 72 |
# File 'lib/eve/message.rb', line 70 def print_app_interrupted(id) print "Interrupted eve #{id}, should now be in shell mode\n" end |
#print_appid(appid) ⇒ Object
115 116 117 |
# File 'lib/eve/message.rb', line 115 def print_appid(appid) print "Appid: #{appid}\n" end |
#print_cmd_error(cmd, e = nil) ⇒ Object
106 107 108 109 |
# File 'lib/eve/message.rb', line 106 def print_cmd_error(cmd,e = nil) msg = "An error occurred for '#{cmd}'" e.nil? ? print("#{msg}\n") : print_error(msg,e) end |
#print_error(msg, error) ⇒ Object
20 21 22 23 24 |
# File 'lib/eve/message.rb', line 20 def print_error(msg, error) print "#{msg}\n" print " #{error.}\n" print " " + error.backtrace.join("\n ") + "\n" end |
#print_event_mode(where) ⇒ Object
66 67 68 |
# File 'lib/eve/message.rb', line 66 def print_event_mode(where) print "Messages will be routed to #{where}\n" end |
#print_exit ⇒ Object
30 31 32 |
# File 'lib/eve/message.rb', line 30 def print_exit print "bye\n" end |
#print_exported_commands(filename) ⇒ Object
87 88 89 |
# File 'lib/eve/message.rb', line 87 def print_exported_commands(filename) print "Exported all commands to #{filename} -- reload using 'import #{filename}'\n" end |
#print_help(cmds, handler = nil) ⇒ Object
80 81 82 83 84 85 |
# File 'lib/eve/message.rb', line 80 def print_help(cmds,handler = nil) msg = handler.nil? || handler == "" ? "Available commands are:\n" : "Available commands (#{handler}) are:\n" msg += cmds.collect { |call,sub_calls| sub_calls.empty? ? " #{call}" : " #{call} [ #{sub_calls.join(" | ")} ]" }.join("\n") msg += "\n" print msg end |
#print_importing_commands(filename) ⇒ Object
91 92 93 |
# File 'lib/eve/message.rb', line 91 def print_importing_commands(filename) print "Importing comamnds from #{filename}\n" end |
#print_importing_complete(filename, count) ⇒ Object
95 96 97 98 99 100 101 102 103 104 |
# File 'lib/eve/message.rb', line 95 def print_importing_complete(filename,count) case count when 0 print "No commands found!\n" when 1 print "Finished importing #{count} command (#{filename})\n" else print "Finished importing #{count} commands (#{filename})\n" end end |
#print_poll_details(in_secs, cmds) ⇒ Object
50 51 52 53 54 55 56 57 58 59 |
# File 'lib/eve/message.rb', line 50 def print_poll_details(in_secs, cmds) output = Message.friendly_duration(in_secs) if cmds.empty? print "Poll will check every #{output}, but it has nothing to run.\n" else msg = "Poll will check every #{output}, and send the following events:\n" cmds.each { |cmd| msg += " - #{cmd}\n" } print msg end end |
#print_poll_mode(id, in_secs) ⇒ Object
61 62 63 64 |
# File 'lib/eve/message.rb', line 61 def print_poll_mode(id,in_secs) output = Message.friendly_duration(in_secs) print "Entering poll mode with checks every #{output}, to exit this mode, run 'eve --interrupt #{id}' from another terminal session\n" end |
#print_process_id(id) ⇒ Object
38 39 40 |
# File 'lib/eve/message.rb', line 38 def print_process_id(id) print "Process Id: #{id}\n" end |
#print_registry(registries) ⇒ Object
127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/eve/message.rb', line 127 def print_registry(registries) if registries.empty? print "Nothing registered.\n" else msg = "The following has been registered:\n" registries.each do |classname,files| msg += " - #{classname} (#{files.join(", ")})\n" end print msg end end |
#print_registry_path(paths) ⇒ Object
139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'lib/eve/message.rb', line 139 def print_registry_path(paths) if paths.empty? print "No paths have been provided.\n" else msg = "The following paths have been set:\n" paths.each do |p| msg += " -- #{p}\n" end print msg end end |
#print_registry_reloaded ⇒ Object
123 124 125 |
# File 'lib/eve/message.rb', line 123 def print_registry_reloaded print "Registry reloaded.\n" end |
#print_ruby_call(call, answer) ⇒ Object
42 43 44 |
# File 'lib/eve/message.rb', line 42 def print_ruby_call(call,answer) print "#{call}: #{answer}\n" end |
#print_server_init ⇒ Object
111 112 113 |
# File 'lib/eve/message.rb', line 111 def print_server_init print "Connection Established\n" end |
#print_shell_mode ⇒ Object
46 47 48 |
# File 'lib/eve/message.rb', line 46 def print_shell_mode print "Entering shell mode, to exit this mode, type 'poll'\n" end |
#print_sleep(in_secs) ⇒ Object
74 75 76 77 78 |
# File 'lib/eve/message.rb', line 74 def print_sleep(in_secs) friendly = WatchMe::Timer.calculate_duration_to_s(in_secs) seconds = "#{in_secs} seconds" print friendly == seconds ? "Sleeping for #{friendly}\n" : "Sleeping for #{friendly} (#{seconds})\n" end |
#print_system_call(cmd) ⇒ Object
26 27 28 |
# File 'lib/eve/message.rb', line 26 def print_system_call(cmd) print "CALLING: #{cmd}\n", {} , "system_calls" end |
#print_unknown_cmd(cmd) ⇒ Object
34 35 36 |
# File 'lib/eve/message.rb', line 34 def print_unknown_cmd(cmd) print "UNKNOWN CMD: #{cmd}\n" end |
#print_unknown_handler(name) ⇒ Object
119 120 121 |
# File 'lib/eve/message.rb', line 119 def print_unknown_handler(name) print "Unknown handler Blah\n" end |
#print_version(appid, show_multiple_times = true) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/eve/message.rb', line 11 def print_version(appid,show_multiple_times = true) if appid.nil? print "eve, version #{Eve::VERSION}\n" else app_full_id = appid.to_s == $$.to_s ? appid : "#{appid} (#{$$})" print "eve #{app_full_id}, version #{Eve::VERSION}\n" end end |