class Fastlane::Helper::AppInfoHelper

Constants

COMMON_COLUMNS

Public Class Methods

android_certificate_issuer(app) click to toggle source
# File lib/fastlane/plugin/app_info/helper/app_info_helper.rb, line 86
def self.android_certificate_issuer(app)
  app.certificates.each_with_object([]) do |cert, obj|
    issuer = cert.certificate.issuer.to_a.map {|c| [c[0], c[1]] }.flatten.each_slice(2).to_h
    obj << issuer.select{ |k, _| ['CN', 'OU', 'O'].include?(k) }
                 .map {|k, v| "#{k}:#{v}"}
                 .join(' ')
  end
end
column_name(key, value) click to toggle source
# File lib/fastlane/plugin/app_info/helper/app_info_helper.rb, line 71
def self.column_name(key, value)
  case value
  when Array
    value.size > 1 ? "#{key} (#{value.size})" : key
  when Hash
    value.keys.size > 1 ? "#{key} (#{value.keys.size})" : key
  else
    key
  end
end
common_columns(app) click to toggle source
# File lib/fastlane/plugin/app_info/helper/app_info_helper.rb, line 53
def self.common_columns(app)
  COMMON_COLUMNS.each_with_object({}) do |key, hash|
    value = key == 'size' ? app.size(true) : app.send(key.to_sym)
    hash[upcase(key)] = value
  end
end
hash_to_columns(raw) click to toggle source
# File lib/fastlane/plugin/app_info/helper/app_info_helper.rb, line 8
def self.hash_to_columns(raw)
  raw.each_with_object({}) do |(key, value), obj|
    next if value.respond_to?(:empty?) && value.empty?

    name = upcase(column_name(key, value))
    obj[name] = object_to_column(value)
  end
end
object_to_column(object) click to toggle source
# File lib/fastlane/plugin/app_info/helper/app_info_helper.rb, line 60
def self.object_to_column(object)
  case object
  when Hash
    object.collect { |k, v| "#{k}: #{v}" }.join("\n")
  when Array
    object.join("\n")
  else
    object.to_s
  end
end
platform_columns(app) click to toggle source
# File lib/fastlane/plugin/app_info/helper/app_info_helper.rb, line 21
def self.platform_columns(app)
  obj = {}

  if app.os == 'iOS'
    obj[upcase('release_type')] = app.release_type
    obj[upcase('archs')] = app.archs
    return {} unless app.mobileprovision && !app.mobileprovision.empty?

    app.mobileprovision.mobileprovision.each do |key, value|
      next if key == 'DeveloperCertificates' || key == 'Name' || key == 'DER-Encoded-Profile'

      obj[upcase(key)] = value
    end
  elsif app.os == 'Android'
    signs = app.signs.map { |f| f.path }
    issuers = android_certificate_issuer(app)
    permissions = app.use_permissions
    features = app.use_features

    obj = {
      "MinSDKVersion" => app.min_sdk_version,
      "TargetSDKVersion" => app.target_sdk_version,
      "Signatures" => signs,
      "CertificateIssuers" => issuers,
      "UsePermissions" => permissions,
      "UseFeatures" => features,
    }
  end

  obj
end
raw_data(app) click to toggle source
# File lib/fastlane/plugin/app_info/helper/app_info_helper.rb, line 17
def self.raw_data(app)
  common_columns(app).merge(platform_columns(app))
end
store_sharedvalue(key, value) click to toggle source
# File lib/fastlane/plugin/app_info/helper/app_info_helper.rb, line 95
def self.store_sharedvalue(key, value)
  Actions.lane_context[key] = value
  ENV[key.to_s] = value

  value
end
upcase(key) click to toggle source
# File lib/fastlane/plugin/app_info/helper/app_info_helper.rb, line 82
def self.upcase(key)
  key == 'os' ? key.upcase : key.split('_').map(&:capitalize).join('')
end