Class: Fastlane::Actions::RustoreDeveloperStatusAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/rustore_developer/actions/rustore_developer_status_action.rb

Class Method Summary collapse

Class Method Details

.authorsObject


75
76
77
# File 'lib/fastlane/plugin/rustore_developer/actions/rustore_developer_status_action.rb', line 75

def self.authors
  ["RimiX2"]
end

.available_optionsObject


88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/fastlane/plugin/rustore_developer/actions/rustore_developer_status_action.rb', line 88

def self.available_options
  [
      FastlaneCore::ConfigItem.new(key: :package,
                                   env_name: "RUSTORE_PACKAGE_NAME",
                                   description: "Android app package name (FQDN)",
                                   optional: false,
                                   type: String),
      FastlaneCore::ConfigItem.new(key: :version,
                                   description: "Version ID",
                                   optional: true,
                                   type: String,
                                   default_value: Actions.lane_context[SharedValues::RUSTORE_DEVELOPER_DRAFT_VERSION]),
      FastlaneCore::ConfigItem.new(key: :table_view,
                                   env_name: "RUSTORE_TABLE_VIEW",
                                   description: "Show result in a tabular format",
                                   optional: true,
                                   type: Boolean,
                                   default_value: false),
      FastlaneCore::ConfigItem.new(key: :token,
                                   description: "Access token",
                                   optional: false,
                                   sensitive: true,
                                   default_value: Actions.lane_context[SharedValues::RUSTORE_DEVELOPER_ACCESS_TOKEN],
                                   verify_block: proc do |value|
                                     UI.user_error!("No access token given, pass using `token: 'token_value'`") unless value && !value.empty?
                                   end,
                                   type: String)
  ]
end

.descriptionObject


71
72
73
# File 'lib/fastlane/plugin/rustore_developer/actions/rustore_developer_status_action.rb', line 71

def self.description
  "RUSTORE: Get app statuses for the last 100 versions"
end

.detailsObject


83
84
85
86
# File 'lib/fastlane/plugin/rustore_developer/actions/rustore_developer_status_action.rb', line 83

def self.details
  # Optional:
  ""
end

.display(data, table_view) ⇒ Object


18
19
20
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/fastlane/plugin/rustore_developer/actions/rustore_developer_status_action.rb', line 18

def self.display(data, table_view)
    if table_view
            # puts(data)
            exclude_cols = ['paid', 'priceValue', 'whatsNew', 'partialValue', 'sendDateForModer', 'publishDateTime', 'testingType']
            col_labels = { versionId: "ID",
                          appName: "Title",
                          appType: "AppType",
                          versionName: "vName",
                          versionCode: "vCode",
                          versionStatus: "Status",
                          publishType: 'PublishType',
                          publishDateTime: 'Published',
                          sendDateForModer: 'Commited',
                          partialValue: 'Part',
                          whatsNew: 'Changelog',
                          priceValue: 'Price',
                          paid: 'Paid' }

            @columns = col_labels.each_with_object({}) do |(col, label), h|
              h[col] = { label: label,
                        width: [[data.map { |g| g[col.to_s].to_s.size }.max, 30].min, label.size].max }
            end

            # header top line
            puts("+-#{@columns.map { |_, g| '-' * g[:width] }.join('-+-')}-+")
            # header line
            puts("| #{@columns.map { |_, g| g[:label].to_s.ljust(g[:width]) }.join(' | ')} |")
            # # header bottom line
            puts("+-#{@columns.map { |_, g| '-' * g[:width] }.join('-+-')}-+")

            # row line
            data.each do |row|
              str = row.keys.map do |k|
                a = row[k]
                if a.to_s.size > 30
                  a = "#{a.to_s[0..26]}..."
                end
                if a
                  # if @columns[k.to_sym]
                  a.to_s.ljust(@columns[k.to_sym][:width])
                else
                  a.to_s
                end
              end.join(' | ')
              puts("| #{str} |")
            end
            # bottom line
            puts("+-#{@columns.map { |_, g| '-' * g[:width] }.join('-+-')}-+")
    else
      puts(data)
    end
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)

118
119
120
121
# File 'lib/fastlane/plugin/rustore_developer/actions/rustore_developer_status_action.rb', line 118

def self.is_supported?(platform)
  [:android].include?(platform)
  true
end

.return_valueObject


79
80
81
# File 'lib/fastlane/plugin/rustore_developer/actions/rustore_developer_status_action.rb', line 79

def self.return_value
  ""
end

.run(params) ⇒ Object


7
8
9
10
11
12
13
14
15
16
# File 'lib/fastlane/plugin/rustore_developer/actions/rustore_developer_status_action.rb', line 7

def self.run(params)
  if params[:version].nil?
    data = Helper::RustoreDeveloperHelper.getStatusAll(params[:token], params[:package])
    display(data, params[:table_view])
  else
    data = Helper::RustoreDeveloperHelper.getStatus(params[:token], params[:package], params[:version])
    display(data, params[:table_view])
    # puts(data)
  end
end