class Fastlane::Actions::SpaceshipStatsAction

Public Class Methods

author() click to toggle source
# File fastlane/lib/fastlane/actions/spaceship_stats.rb, line 68
def self.author
  "joshdholtz"
end
available_options() click to toggle source
# File fastlane/lib/fastlane/actions/spaceship_stats.rb, line 49
def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :print_request_logs,
                                 description: "Print all URLs requested",
                                 type: Boolean,
                                 default_value: false)
  ]
end
category() click to toggle source
# File fastlane/lib/fastlane/actions/spaceship_stats.rb, line 64
def self.category
  :misc
end
description() click to toggle source
# File fastlane/lib/fastlane/actions/spaceship_stats.rb, line 41
def self.description
  "Print out Spaceship stats from this session (number of request to each domain)"
end
example_code() click to toggle source
# File fastlane/lib/fastlane/actions/spaceship_stats.rb, line 58
def self.example_code
  [
    'spaceship_stats'
  ]
end
is_supported?(platform) click to toggle source
# File fastlane/lib/fastlane/actions/spaceship_stats.rb, line 45
def self.is_supported?(platform)
  true
end
run(params) click to toggle source
# File fastlane/lib/fastlane/actions/spaceship_stats.rb, line 4
def self.run(params)
  require 'fastlane_core/print_table'
  require 'spaceship'

  rows = []
  Spaceship::StatsMiddleware.service_stats.each do |service, count|
    rows << [service.name, service.auth_type, service.url, count]
  end

  puts("")
  puts(Terminal::Table.new(
         title: "Spaceship Stats",
         headings: ["Service", "Auth Type", "URL", "Number of requests"],
         rows: FastlaneCore::PrintTable.transform_output(rows)
  ))
  puts("")

  if params[:print_request_logs]
    log_rows = []
    Spaceship::StatsMiddleware.request_logs.each do |request_log|
      log_rows << [request_log.auth_type, request_log.url]
    end

    puts("")
    puts(Terminal::Table.new(
           title: "Spaceship Request Log",
           headings: ["Auth Type", "URL"],
           rows: FastlaneCore::PrintTable.transform_output(log_rows)
    ))
    puts("")
  end
end
url_name(url_prefix) click to toggle source
# File fastlane/lib/fastlane/actions/spaceship_stats.rb, line 37
def self.url_name(url_prefix)
  Spaceship::StatsMiddleware::URL_PREFIXES[url_prefix]
end