Class: Fastlane::Helper::AppEnvironmentSelector
- Inherits:
-
Object
- Object
- Fastlane::Helper::AppEnvironmentSelector
- Defined in:
- lib/fastlane/plugin/shuttle/helper/app_environment_selector.rb
Class Method Summary collapse
- .create_app_interactive(shuttle_instance, package_info, helper) ⇒ Object
- .create_environment_interactive(shuttle_instance, app, package_info, helper) ⇒ Object
- .desambiguate_app_environment(app_environments, package_info, helper) ⇒ Object
- .get_app_env_from_params(shuttle_instance, package_info, params, helper) ⇒ Object
-
.get_app_environment(shuttle_instance, package_info, params) ⇒ Object
class methods that you define here become available in your action as ‘Helper::ShuttleHelper.your_method`.
- .get_app_interactive(shuttle_instance, package_info, helper) ⇒ Object
- .get_env_interactive(shuttle_instance, app, package_info, helper) ⇒ Object
Class Method Details
.create_app_interactive(shuttle_instance, package_info, helper) ⇒ Object
85 86 87 88 89 |
# File 'lib/fastlane/plugin/shuttle/helper/app_environment_selector.rb', line 85 def self.create_app_interactive(shuttle_instance, package_info, helper) app_name = UI.input("app name (default: #{package_info.name}): ") app_name = package_info.name if app_name.to_s.empty? helper.create_app(shuttle_instance, app_name, package_info.platform_id) end |
.create_environment_interactive(shuttle_instance, app, package_info, helper) ⇒ Object
108 109 110 111 112 113 114 |
# File 'lib/fastlane/plugin/shuttle/helper/app_environment_selector.rb', line 108 def self.create_environment_interactive(shuttle_instance, app, package_info, helper) env_name = UI.input("environment name: ") versioning_id_choices = ["version_only", "version_and_build"] choice_index = helper.prompt_choices("environment version scheme:", versioning_id_choices, "interactive mode needed") app_name = package_info.name if app_name.to_s.empty? helper.create_environment(shuttle_instance, env_name, versioning_id_choices[choice_index], app.id, package_info.id) end |
.desambiguate_app_environment(app_environments, package_info, helper) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/fastlane/plugin/shuttle/helper/app_environment_selector.rb', line 56 def self.desambiguate_app_environment(app_environments, package_info, helper) = app_environments.map do |app_env| "#{app_env.shuttle_app.name} (#{app_env.shuttle_environment.name})" end choice_index = helper.prompt_choices( "Can't guess which app and environment to use, please choose the correct one:", , "Too many environments with package id #{package_info.id} for #{package_info.platform_id}" ) app_environment = app_environments[choice_index] end |
.get_app_env_from_params(shuttle_instance, package_info, params, helper) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/fastlane/plugin/shuttle/helper/app_environment_selector.rb', line 43 def self.get_app_env_from_params(shuttle_instance, package_info, params, helper) env_id = params[:env_id] return nil if env_id.to_s.empty? environment = helper.get_environment(shuttle_instance, env_id) app = helper.get_app(shuttle_instance, environment.app_id) return AppEnvironment.new(app, environment) if environment.package_id == package_info.id && app.platform_id == package_info.platform_id UI.important("App #{app.name} doesn't match the given build platform #{package_info.platform_id}, please check that #{env_id} is the correct environment ID.") unless app.platform_id == package_info.platform_id UI.important("Environment #{environment.name} with ID #{env_id} doesn't match the build's package ID #{package_info.id}, please check that you set the correct environment ID") unless environment.package_id == package_info.id return nil end |
.get_app_environment(shuttle_instance, package_info, params) ⇒ Object
class methods that you define here become available in your action as ‘Helper::ShuttleHelper.your_method`
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 |
# File 'lib/fastlane/plugin/shuttle/helper/app_environment_selector.rb', line 11 def self.get_app_environment(shuttle_instance, package_info, params) helper = Helper::ShuttleHelper app_environment = self.get_app_env_from_params(shuttle_instance, package_info, params, helper) return app_environment unless app_environment.nil? all_environments = helper.get_environments(shuttle_instance) app_environment = nil environments = all_environments.select do |env| env.package_id == package_info.id end app_environments = helper.get_app_environments(shuttle_instance, environments).select do |app_env| app_env.shuttle_app.platform_id == package_info.platform_id end if app_environments.empty? app = self.get_app_interactive(shuttle_instance, package_info, helper) env = self.get_env_interactive(shuttle_instance, app, package_info, helper) app_environment = AppEnvironment.new(app, env) else if app_environments.count == 1 app_environment = app_environments[0] else app_environment = self.desambiguate_app_environment(app_environments, package_info, helper) end end return app_environment end |
.get_app_interactive(shuttle_instance, package_info, helper) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/fastlane/plugin/shuttle/helper/app_environment_selector.rb', line 68 def self.get_app_interactive(shuttle_instance, package_info, helper) apps = helper.get_apps(shuttle_instance).select do |app| app.platform_id == package_info.platform_id end = apps.map do |app| "#{app.name}" end create_new_option = "Create a new one…" choice_index = helper.prompt_choices( "Can't guess which app to use, please choose the correct one:", << create_new_option, "No environments configured for package id #{package_info.id}" ) return self.create_app_interactive(shuttle_instance, package_info, helper) if [choice_index] == create_new_option return apps[choice_index] end |
.get_env_interactive(shuttle_instance, app, package_info, helper) ⇒ Object
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/fastlane/plugin/shuttle/helper/app_environment_selector.rb', line 91 def self.get_env_interactive(shuttle_instance, app, package_info, helper) environments = helper.get_environments_for_app(shuttle_instance, app).select do |env| env.package_id == package_info.id end = environments.map do |env| "#{env.name}" end create_new_option = "Create a new one…" choice_index = helper.prompt_choices( "Can't guess which #{app.name}'s environment to use, please choose the correct one:", << create_new_option, "No environments configured for package id #{package_info.id}" ) return self.create_environment_interactive(shuttle_instance, app, package_info, helper) if [choice_index] == create_new_option return environments[choice_index] end |