Class: Fastlane::Actions::SpaceshipStatsAction

Inherits:
Fastlane::Action show all
Defined in:
fastlane/lib/fastlane/actions/spaceship_stats.rb

Constant Summary

Constants inherited from Fastlane::Action

Fastlane::Action::AVAILABLE_CATEGORIES, Fastlane::Action::RETURN_TYPES

Class Method Summary collapse

Methods inherited from Fastlane::Action

action_name, authors, deprecated_notes, details, lane_context, method_missing, other_action, output, return_type, return_value, sample_return_value, shell_out_should_use_bundle_exec?, step_text

Class Method Details

.authorObject



68
69
70
# File 'fastlane/lib/fastlane/actions/spaceship_stats.rb', line 68

def self.author
  "joshdholtz"
end

.available_optionsObject



49
50
51
52
53
54
55
56
# 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

.categoryObject



64
65
66
# File 'fastlane/lib/fastlane/actions/spaceship_stats.rb', line 64

def self.category
  :misc
end

.descriptionObject



41
42
43
# 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_codeObject



58
59
60
61
62
# File 'fastlane/lib/fastlane/actions/spaceship_stats.rb', line 58

def self.example_code
  [
    'spaceship_stats'
  ]
end

.is_supported?(platform) ⇒ Boolean

Returns:



45
46
47
# File 'fastlane/lib/fastlane/actions/spaceship_stats.rb', line 45

def self.is_supported?(platform)
  true
end

.run(params) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# 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) ⇒ Object



37
38
39
# File 'fastlane/lib/fastlane/actions/spaceship_stats.rb', line 37

def self.url_name(url_prefix)
  Spaceship::StatsMiddleware::URL_PREFIXES[url_prefix]
end