Class: Lita::Handlers::ServerStatus
- Inherits:
-
Handler
- Object
- Handler
- Lita::Handlers::ServerStatus
- Defined in:
- lib/lita/handlers/server_status.rb
Constant Summary collapse
- MESSAGE_REGEX =
%r/(?::eyes:\s)*(.+) is deploying (.+)\/(.+) to (.+)/i
Instance Method Summary collapse
- #formatted_time ⇒ Object
- #list_statuses(response) ⇒ Object
- #save_status(response) ⇒ Object
- #status_message ⇒ Object
Instance Method Details
#formatted_time ⇒ Object
30 31 32 |
# File 'lib/lita/handlers/server_status.rb', line 30 def formatted_time Time.now.strftime('%Y-%m-%d %H:%M') end |
#list_statuses(response) ⇒ Object
20 21 22 |
# File 'lib/lita/handlers/server_status.rb', line 20 def list_statuses(response) response.reply end |
#save_status(response) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/lita/handlers/server_status.rb', line 11 def save_status(response) = response..body user, application, branch, environment = .match(MESSAGE_REGEX).captures apply_status = { id: "#{application}:#{environment}", message: "#{application} #{environment}: #{branch} (#{user} @ #{formatted_time})" } redis.set("server_status:#{apply_status[:id]}", apply_status[:message]) end |
#status_message ⇒ Object
24 25 26 27 28 |
# File 'lib/lita/handlers/server_status.rb', line 24 def = redis.keys('server_status*').sort.map { |key| redis.get(key) } << 'I don\'t know what state the servers are in.' if .empty? .join("\n") end |