Module: Fastlane::Helper::FirebaseAppDistributionHelper

Instance Method Summary collapse

Instance Method Details

#app_name_from_app_id(app_id) ⇒ Object



61
62
63
# File 'lib/fastlane/plugin/firebase_app_distribution/helper/firebase_app_distribution_helper.rb', line 61

def app_name_from_app_id(app_id)
  "#{project_name(project_number_from_app_id(app_id))}/apps/#{app_id}"
end

#binary_type_from_path(binary_path) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/fastlane/plugin/firebase_app_distribution/helper/firebase_app_distribution_helper.rb', line 8

def binary_type_from_path(binary_path)
  extension = File.extname(binary_path)
  return :APK if extension == '.apk'
  return :AAB if extension == '.aab'
  return :IPA if extension == '.ipa'

  UI.user_error!("Unsupported distribution file format, should be .ipa, .apk or .aab")
end

#blank?(value) ⇒ Boolean

Returns:

  • (Boolean)


48
49
50
51
# File 'lib/fastlane/plugin/firebase_app_distribution/helper/firebase_app_distribution_helper.rb', line 48

def blank?(value)
  # Taken from https://apidock.com/rails/Object/blank%3F
  value.respond_to?(:empty?) ? value.empty? : !value
end

#deep_symbolize_keys(hash) ⇒ Object



86
87
88
89
90
91
92
# File 'lib/fastlane/plugin/firebase_app_distribution/helper/firebase_app_distribution_helper.rb', line 86

def deep_symbolize_keys(hash)
  result = {}
  hash.each do |key, value|
    result[key.to_sym] = value.kind_of?(Hash) ? deep_symbolize_keys(value) : value
  end
  result
end

#get_ios_app_id_from_archive_plist(archive_path, plist_path) ⇒ Object



40
41
42
43
44
45
46
# File 'lib/fastlane/plugin/firebase_app_distribution/helper/firebase_app_distribution_helper.rb', line 40

def get_ios_app_id_from_archive_plist(archive_path, plist_path)
  app_path = parse_plist("#{archive_path}/Info.plist")["ApplicationProperties"]["ApplicationPath"]
  UI.shell_error!("can't extract application path from Info.plist at #{archive_path}") if app_path.empty?
  identifier = parse_plist("#{archive_path}/Products/#{app_path}/#{plist_path}")["GOOGLE_APP_ID"]
  UI.shell_error!("can't extract GOOGLE_APP_ID") if identifier.empty?
  return identifier
end

#get_value_from_value_or_file(value, path) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# File 'lib/fastlane/plugin/firebase_app_distribution/helper/firebase_app_distribution_helper.rb', line 17

def get_value_from_value_or_file(value, path)
  if (value.nil? || value.empty?) && !path.nil?
    begin
      return File.open(path).read
    rescue Errno::ENOENT
      UI.crash!("#{ErrorMessage::INVALID_PATH}: #{path}")
    end
  end
  value
end

#group_name(project_number, group_alias) ⇒ Object



69
70
71
# File 'lib/fastlane/plugin/firebase_app_distribution/helper/firebase_app_distribution_helper.rb', line 69

def group_name(project_number, group_alias)
  "#{project_name(project_number)}/groups/#{group_alias}"
end

#init_google_api_client(debug, timeout = nil) ⇒ Object



73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/fastlane/plugin/firebase_app_distribution/helper/firebase_app_distribution_helper.rb', line 73

def init_google_api_client(debug, timeout = nil)
  if debug
    UI.important("Warning: Debug logging enabled. Output may include sensitive information.")
    Google::Apis.logger.level = Logger::DEBUG
  end

  Google::Apis::ClientOptions.default.application_name = "fastlane"
  Google::Apis::ClientOptions.default.application_version = Fastlane::FirebaseAppDistribution::VERSION
  unless timeout.nil?
    Google::Apis::ClientOptions.default.send_timeout_sec = timeout
  end
end

#parse_plist(path) ⇒ Object



36
37
38
# File 'lib/fastlane/plugin/firebase_app_distribution/helper/firebase_app_distribution_helper.rb', line 36

def parse_plist(path)
  CFPropertyList.native_types(CFPropertyList::List.new(file: path).value)
end

#present?(value) ⇒ Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/fastlane/plugin/firebase_app_distribution/helper/firebase_app_distribution_helper.rb', line 53

def present?(value)
  !blank?(value)
end

#project_name(project_number) ⇒ Object



65
66
67
# File 'lib/fastlane/plugin/firebase_app_distribution/helper/firebase_app_distribution_helper.rb', line 65

def project_name(project_number)
  "projects/#{project_number}"
end

#project_number_from_app_id(app_id) ⇒ Object



57
58
59
# File 'lib/fastlane/plugin/firebase_app_distribution/helper/firebase_app_distribution_helper.rb', line 57

def project_number_from_app_id(app_id)
  app_id.split(':')[1]
end

#string_to_array(string, delimiter = ",") ⇒ Object

Returns the array representation of a string with trimmed comma seperated values.



30
31
32
33
34
# File 'lib/fastlane/plugin/firebase_app_distribution/helper/firebase_app_distribution_helper.rb', line 30

def string_to_array(string, delimiter = ",")
  return [] if string.nil?
  # Strip string and then strip individual values
  string.strip.split(delimiter).map(&:strip)
end