Class: NeetoDeploy::CLI::Activity::List
- Includes:
- Session
- Defined in:
- lib/neeto_deploy/cli/activity/list.rb
Constant Summary
Constants included from Session
Instance Attribute Summary collapse
-
#app_slug ⇒ Object
readonly
Returns the value of attribute app_slug.
-
#page ⇒ Object
readonly
Returns the value of attribute page.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(options:) ⇒ List
constructor
A new instance of List.
- #run ⇒ Object
Methods included from Session
#auth_headers, #console_executable_name, #json_auth_headers, #os, require_app_option, #send_delete_request, #send_get_request, #send_patch_request, #send_post_request
Methods inherited from Base
Constructor Details
#initialize(options:) ⇒ List
Returns a new instance of List.
14 15 16 17 18 19 |
# File 'lib/neeto_deploy/cli/activity/list.rb', line 14 def initialize(options:) super() @app_slug = [:app] @type = [:type] @page = [:page] || 1 end |
Instance Attribute Details
#app_slug ⇒ Object (readonly)
Returns the value of attribute app_slug.
12 13 14 |
# File 'lib/neeto_deploy/cli/activity/list.rb', line 12 def app_slug @app_slug end |
#page ⇒ Object (readonly)
Returns the value of attribute page.
12 13 14 |
# File 'lib/neeto_deploy/cli/activity/list.rb', line 12 def page @page end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
12 13 14 |
# File 'lib/neeto_deploy/cli/activity/list.rb', line 12 def type @type end |
Instance Method Details
#run ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/neeto_deploy/cli/activity/list.rb', line 21 def run ui.execute_with_loading("Fetching activity...") do body = { app_slug: } body[:type] = type if type body[:page] = page @response = send_get_request("#{NEETO_DEPLOY_CLI_API_BASE_URL}/activities", body) end return ui.error(@response["error"] || @response.) unless @response.success? parsed = JSON.parse(@response.body) activities = parsed["activities"] if activities.nil? || activities.empty? ui.info("No activity found for #{app_slug}.") return end rows = activities.map do |a| performer = a["performer"] || "system" = a["metadata"]&.map { |k, v| "#{k}: #{v}" }&.join(", ") || "" = "#{metadata[0..97]}..." if .length > 100 [a["key"], a["performed_at"], performer, ] end table = Terminal::Table.new(headings: ["Event", "Time", "By", "Details"], rows: rows) ui.info(table) ui.info("Page #{parsed["current_page"]} of #{parsed["total_pages"]}") end |