Class: Lita::Handlers::Info
- Inherits:
-
Lita::Handler
- Object
- Lita::Handler
- Lita::Handlers::Info
- Defined in:
- lib/lita/handlers/info.rb
Overview
Provides information about the currently running robot.
Instance Method Summary collapse
-
#chat(response) ⇒ void
Replies with the current version of Lita, the current version of Redis, and Redis memory usage.
-
#redis_info ⇒ Object
A hash of information about Redis.
-
#redis_memory_usage ⇒ Object
The amount of memory Redis is using.
-
#redis_version ⇒ Object
The current version of Redis.
-
#web(_request, response) ⇒ void
Returns JSON with basic information about the robot.
Methods included from Lita::Handler::ChatRouter
#dispatch, #dispatch_to_route, extended, #route, #routes
Methods included from Lita::Handler::HTTPRouter
Methods included from Lita::Handler::EventRouter
#event_subscriptions_for, extended, #on, #trigger
Instance Method Details
#chat(response) ⇒ void
This method returns an undefined value.
Replies with the current version of Lita, the current version of Redis, and Redis memory usage.
17 18 19 20 21 22 |
# File 'lib/lita/handlers/info.rb', line 17 def chat(response) response.reply( %(Lita #{Lita::VERSION} - https://www.lita.io/), %(Redis #{redis_version} - Memory used: #{redis_memory_usage}) ) end |
#redis_info ⇒ Object
A hash of information about Redis.
42 43 44 45 46 47 48 |
# File 'lib/lita/handlers/info.rb', line 42 def redis_info @redis_info ||= begin r = redis.redis r = r.redis while r.respond_to?(:redis) r.info end end |
#redis_memory_usage ⇒ Object
The amount of memory Redis is using.
56 57 58 |
# File 'lib/lita/handlers/info.rb', line 56 def redis_memory_usage redis_info["used_memory_human"] end |
#redis_version ⇒ Object
The current version of Redis.
51 52 53 |
# File 'lib/lita/handlers/info.rb', line 51 def redis_version redis_info["redis_version"] end |
#web(_request, response) ⇒ void
This method returns an undefined value.
Returns JSON with basic information about the robot.
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/lita/handlers/info.rb', line 28 def web(_request, response) response.headers["Content-Type"] = "application/json" json = MultiJson.dump( adapter: robot.config.robot.adapter, lita_version: Lita::VERSION, redis_memory_usage: redis_memory_usage, redis_version: redis_version, robot_mention_name: robot.mention_name, robot_name: robot.name ) response.write(json) end |