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



63
64
65
# File 'lib/fastlane/plugin/rustore_developer/actions/rustore_developer_status_action.rb', line 63

def self.authors
  ["RimiX2"]
end

.available_optionsObject



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/fastlane/plugin/rustore_developer/actions/rustore_developer_status_action.rb', line 76

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: :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



59
60
61
# File 'lib/fastlane/plugin/rustore_developer/actions/rustore_developer_status_action.rb', line 59

def self.description
  "RUSTORE: Get app versions statuses"
end

.detailsObject



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

def self.details
  # Optional:
  ""
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


100
101
102
103
# File 'lib/fastlane/plugin/rustore_developer/actions/rustore_developer_status_action.rb', line 100

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

.return_valueObject



67
68
69
# File 'lib/fastlane/plugin/rustore_developer/actions/rustore_developer_status_action.rb', line 67

def self.return_value
  ""
end

.run(params) ⇒ Object



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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/fastlane/plugin/rustore_developer/actions/rustore_developer_status_action.rb', line 8

def self.run(params)
  if params[:version].nil?
    massive = Helper::RustoreDeveloperHelper.getStatusAll(params[:token], params[:package])
    # puts(massive)
    exclude_cols = ['paid', 'priceValue', 'whatsNew', 'partialValue', 'sendDateForModer', 'publishDateTime',]
    col_labels = {versionId: "ID",
                  appName: "Title",
                  appType: "appType",
                  versionName: "vName",
                  versionCode: "vCode",
                  versionStatus: "Status",
                  publishType: 'publishType',
                  publishDateTime: 'Published',
                  sendDateForModer: 'Commited',
                  partialValue: 'Part',
                  whatsNew: 'whatsNew',
                  priceValue: 'Price',
                  paid: 'paid',
    }
    @columns = col_labels.each_with_object({}) { |(col, label), h|
      h[col] = {label: label,
                width: [[(massive.map { |g| g[col.to_s].to_s.size }.max), 30].min, label.size].max}
    }

    # 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
    massive.each do |row|
      str = row.keys.map { |k|
        a = row[k]
        if a.to_s.size > 30 then
          a = a.to_s[0..26] + "..."
        end
        a.to_s.ljust(@columns[k.to_sym][:width])
      }.join(' | ')
      puts "| #{str} |"
    end
    # bottom line
    puts "+-#{@columns.map { |_, g| '-' * g[:width] }.join('-+-')}-+"
  else
    info = Helper::RustoreDeveloperHelper.getStatus(params[:token], params[:package], params[:version])
    puts(info)
  end

end