Class: Pantry::Commands::Status
- Inherits:
-
Pantry::Command
- Object
- Pantry::Command
- Pantry::Commands::Status
- Defined in:
- lib/pantry/commands/status.rb
Instance Attribute Summary collapse
-
#client_filter ⇒ Object
Returns the value of attribute client_filter.
Instance Method Summary collapse
-
#perform(message) ⇒ Object
Return information about all connected Clients that match the given filter.
- #prepare_message(options) ⇒ Object
- #receive_server_response(message) ⇒ Object
- #to_message ⇒ Object
Methods inherited from Pantry::Command
command, #finished, #finished?, #initialize, message_type, #receive_client_response, #receive_response, #send_request, #send_request!, #server_or_client, #server_or_client=, #wait_for_finish
Constructor Details
This class inherits a constructor from Pantry::Command
Instance Attribute Details
#client_filter ⇒ Object
Returns the value of attribute client_filter.
10 11 12 |
# File 'lib/pantry/commands/status.rb', line 10 def client_filter @client_filter end |
Instance Method Details
#perform(message) ⇒ Object
Return information about all connected Clients that match the given filter
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/pantry/commands/status.rb', line 28 def perform() @client_filter = Pantry::Communication::ClientFilter.new(**(.body[0] || {})) self.server.client_registry.all_matching(@client_filter) do |client, record| { identity: client.identity, application: client.application, environment: client.environment, roles: client.roles, last_checked_in: record.last_checked_in_at } end end |
#prepare_message(options) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/pantry/commands/status.rb', line 12 def () @client_filter = Pantry::Communication::ClientFilter.new( application: [:application], environment: [:environment], roles: [:roles] ) super end |
#receive_server_response(message) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/pantry/commands/status.rb', line 41 def receive_server_response() output = clients = .body.map do |client| [ time_ago_in_words(client[:last_checked_in]), client[:identity], "|", client[:application], client[:environment], [client[:roles]].flatten.join(",") ].compact.join(" ") end Pantry.ui.list(output) end |
#to_message ⇒ Object
21 22 23 24 25 |
# File 'lib/pantry/commands/status.rb', line 21 def = super << @client_filter.to_hash end |