Module: Fastlane::Helper::FirebaseAppDistributionHelper
- Included in:
- Actions::FirebaseAppDistributionAction, Actions::FirebaseAppDistributionAddTestersAction, Actions::FirebaseAppDistributionCreateGroupAction, Actions::FirebaseAppDistributionDeleteGroupAction, Actions::FirebaseAppDistributionGetLatestReleaseAction, Actions::FirebaseAppDistributionGetUdidsAction, Actions::FirebaseAppDistributionRemoveTestersAction
- Defined in:
- lib/fastlane/plugin/firebase_app_distribution/helper/firebase_app_distribution_helper.rb
Instance Method Summary collapse
- #app_name_from_app_id(app_id) ⇒ Object
- #binary_type_from_path(binary_path) ⇒ Object
- #blank?(value) ⇒ Boolean
- #deep_symbolize_keys(hash) ⇒ Object
- #get_ios_app_id_from_archive_plist(archive_path, plist_path) ⇒ Object
- #get_value_from_value_or_file(value, path) ⇒ Object
- #group_name(project_number, group_alias) ⇒ Object
- #init_client(client, service_credentials_file, firebase_cli_token, debug, timeout = nil) ⇒ Object
- #init_v1_client(service_credentials_file, firebase_cli_token, debug, timeout = nil) ⇒ Object
- #init_v1alpha_client(service_credentials_file, firebase_cli_token, debug, timeout = nil) ⇒ Object
- #parse_plist(path) ⇒ Object
- #present?(value) ⇒ Boolean
- #project_name(project_number) ⇒ Object
- #project_number_from_app_id(app_id) ⇒ Object
-
#string_to_array(string) ⇒ Object
Returns the array representation of a string with trimmed comma seperated values.
Instance Method Details
#app_name_from_app_id(app_id) ⇒ Object
63 64 65 |
# File 'lib/fastlane/plugin/firebase_app_distribution/helper/firebase_app_distribution_helper.rb', line 63 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
10 11 12 13 14 15 16 17 |
# File 'lib/fastlane/plugin/firebase_app_distribution/helper/firebase_app_distribution_helper.rb', line 10 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
50 51 52 53 |
# File 'lib/fastlane/plugin/firebase_app_distribution/helper/firebase_app_distribution_helper.rb', line 50 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
101 102 103 104 105 106 107 |
# File 'lib/fastlane/plugin/firebase_app_distribution/helper/firebase_app_distribution_helper.rb', line 101 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
42 43 44 45 46 47 48 |
# File 'lib/fastlane/plugin/firebase_app_distribution/helper/firebase_app_distribution_helper.rb', line 42 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
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/fastlane/plugin/firebase_app_distribution/helper/firebase_app_distribution_helper.rb', line 19 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
71 72 73 |
# File 'lib/fastlane/plugin/firebase_app_distribution/helper/firebase_app_distribution_helper.rb', line 71 def group_name(project_number, group_alias) "#{project_name(project_number)}/groups/#{group_alias}" end |
#init_client(client, service_credentials_file, firebase_cli_token, debug, timeout = nil) ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/fastlane/plugin/firebase_app_distribution/helper/firebase_app_distribution_helper.rb', line 85 def init_client(client, service_credentials_file, firebase_cli_token, 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 client. = (service_credentials_file, firebase_cli_token, debug) client end |
#init_v1_client(service_credentials_file, firebase_cli_token, debug, timeout = nil) ⇒ Object
75 76 77 78 |
# File 'lib/fastlane/plugin/firebase_app_distribution/helper/firebase_app_distribution_helper.rb', line 75 def init_v1_client(service_credentials_file, firebase_cli_token, debug, timeout = nil) init_client(Google::Apis::FirebaseappdistributionV1::FirebaseAppDistributionService.new, service_credentials_file, firebase_cli_token, debug, timeout) end |
#init_v1alpha_client(service_credentials_file, firebase_cli_token, debug, timeout = nil) ⇒ Object
80 81 82 83 |
# File 'lib/fastlane/plugin/firebase_app_distribution/helper/firebase_app_distribution_helper.rb', line 80 def init_v1alpha_client(service_credentials_file, firebase_cli_token, debug, timeout = nil) init_client(Google::Apis::FirebaseappdistributionV1alpha::FirebaseAppDistributionService.new, service_credentials_file, firebase_cli_token, debug, timeout) end |
#parse_plist(path) ⇒ Object
38 39 40 |
# File 'lib/fastlane/plugin/firebase_app_distribution/helper/firebase_app_distribution_helper.rb', line 38 def parse_plist(path) CFPropertyList.native_types(CFPropertyList::List.new(file: path).value) end |
#present?(value) ⇒ Boolean
55 56 57 |
# File 'lib/fastlane/plugin/firebase_app_distribution/helper/firebase_app_distribution_helper.rb', line 55 def present?(value) !blank?(value) end |
#project_name(project_number) ⇒ Object
67 68 69 |
# File 'lib/fastlane/plugin/firebase_app_distribution/helper/firebase_app_distribution_helper.rb', line 67 def project_name(project_number) "projects/#{project_number}" end |
#project_number_from_app_id(app_id) ⇒ Object
59 60 61 |
# File 'lib/fastlane/plugin/firebase_app_distribution/helper/firebase_app_distribution_helper.rb', line 59 def project_number_from_app_id(app_id) app_id.split(':')[1] end |
#string_to_array(string) ⇒ Object
Returns the array representation of a string with trimmed comma seperated values.
32 33 34 35 36 |
# File 'lib/fastlane/plugin/firebase_app_distribution/helper/firebase_app_distribution_helper.rb', line 32 def string_to_array(string) return [] if string.nil? # Strip string and then strip individual values string.strip.split(",").map(&:strip) end |