Class: Eve::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/eve/message.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#appObject

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



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


115
116
117
# File 'lib/eve/message.rb', line 115

def print_appid(appid)
  print "Appid: #{appid}\n"
end


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


20
21
22
23
24
# File 'lib/eve/message.rb', line 20

def print_error(msg, error)
  print "#{msg}\n"
  print "  #{error.message}\n"
  print "  " + error.backtrace.join("\n  ") + "\n"
end


66
67
68
# File 'lib/eve/message.rb', line 66

def print_event_mode(where)
  print "Messages will be routed to #{where}\n"
end


30
31
32
# File 'lib/eve/message.rb', line 30

def print_exit
  print "bye\n"
end


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


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


91
92
93
# File 'lib/eve/message.rb', line 91

def print_importing_commands(filename)
  print "Importing comamnds from #{filename}\n"
end


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


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


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


38
39
40
# File 'lib/eve/message.rb', line 38

def print_process_id(id)
  print "Process Id: #{id}\n"
end


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


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


123
124
125
# File 'lib/eve/message.rb', line 123

def print_registry_reloaded
  print "Registry reloaded.\n"
end


42
43
44
# File 'lib/eve/message.rb', line 42

def print_ruby_call(call,answer)
  print "#{call}: #{answer}\n"
end


111
112
113
# File 'lib/eve/message.rb', line 111

def print_server_init
  print "Connection Established\n"
end


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


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


26
27
28
# File 'lib/eve/message.rb', line 26

def print_system_call(cmd)
  print "CALLING: #{cmd}\n", {} , "system_calls"
end


34
35
36
# File 'lib/eve/message.rb', line 34

def print_unknown_cmd(cmd)
  print "UNKNOWN CMD: #{cmd}\n"
end


119
120
121
# File 'lib/eve/message.rb', line 119

def print_unknown_handler(name)
  print "Unknown handler Blah\n"
end


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