Class: BranchIOCLI::Helper::ConfigurationHelper
- Inherits:
-
Object
- Object
- BranchIOCLI::Helper::ConfigurationHelper
- Defined in:
- lib/branch_io_cli/helper/configuration_helper.rb
Class Attribute Summary collapse
-
.all_domains ⇒ Object
Returns the value of attribute all_domains.
-
.keys ⇒ Object
Returns the value of attribute keys.
-
.xcodeproj ⇒ Object
Returns the value of attribute xcodeproj.
Class Method Summary collapse
- .app_link_subdomains(options) ⇒ Object
- .validate_all_domains(options) ⇒ Object
- .validate_keys_from_setup_options(options) ⇒ Object
- .validate_setup_options(options) ⇒ Object
- .validate_validation_options(options) ⇒ Object
-
.xcodeproj_path(options) ⇒ Object
1.
Class Attribute Details
.all_domains ⇒ Object
Returns the value of attribute all_domains.
9 10 11 |
# File 'lib/branch_io_cli/helper/configuration_helper.rb', line 9 def all_domains @all_domains end |
.keys ⇒ Object
Returns the value of attribute keys.
8 9 10 |
# File 'lib/branch_io_cli/helper/configuration_helper.rb', line 8 def keys @keys end |
.xcodeproj ⇒ Object
Returns the value of attribute xcodeproj.
7 8 9 |
# File 'lib/branch_io_cli/helper/configuration_helper.rb', line 7 def xcodeproj @xcodeproj end |
Class Method Details
.app_link_subdomains(options) ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/branch_io_cli/helper/configuration_helper.rb', line 77 def app_link_subdomains() app_link_subdomain = .app_link_subdomain live_key = .live_key test_key = .test_key return [] if live_key.nil? and test_key.nil? return [] if app_link_subdomain.nil? domains = [] unless live_key.nil? domains += [ "#{app_link_subdomain}.app.link", "#{app_link_subdomain}-alternate.app.link" ] end unless test_key.nil? domains += [ "#{app_link_subdomain}.test-app.link", "#{app_link_subdomain}-alternate.test-app.link" ] end domains end |
.validate_all_domains(options) ⇒ Object
40 41 42 43 44 45 46 47 48 |
# File 'lib/branch_io_cli/helper/configuration_helper.rb', line 40 def validate_all_domains() app_link_subdomains = app_link_subdomains custom_domains = .domains || [] @all_domains = (app_link_subdomains + custom_domains).uniq while @all_domains.empty? @all_domains = ask "Please enter domains as a comma-separated list: ", ->(str) { str.split "," } end end |
.validate_keys_from_setup_options(options) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/branch_io_cli/helper/configuration_helper.rb', line 23 def () live_key = .live_key test_key = .test_key @keys = {} @keys[:live] = live_key unless live_key.nil? @keys[:test] = test_key unless test_key.nil? while @keys.empty? say "A live key, a test key or both is required." live_key = ask "Please enter your live Branch key or use --live_key [enter for none]: " test_key = ask "Please enter your test Branch key or use --test_key [enter for none]: " @keys[:live] = live_key unless live_key == "" @keys[:test] = test_key unless test_key == "" end end |
.validate_setup_options(options) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/branch_io_cli/helper/configuration_helper.rb', line 11 def () .xcodeproj = xcodeproj_path validate_all_domains end |
.validate_validation_options(options) ⇒ Object
18 19 20 21 |
# File 'lib/branch_io_cli/helper/configuration_helper.rb', line 18 def () .xcodeproj = xcodeproj_path end |
.xcodeproj_path(options) ⇒ Object
-
Look for options.xcodeproj.
-
If not specified, look for projects under . (excluding anything in Pods or Carthage folder).
-
If none or more than one found, prompt the user.
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/branch_io_cli/helper/configuration_helper.rb', line 53 def xcodeproj_path() if .xcodeproj path = .xcodeproj else all_xcodeproj_paths = Dir[File.(File.join(".", "**/*.xcodeproj"))] # find an xcodeproj (ignoring the Pods and Carthage folders) # TODO: Improve this filter xcodeproj_paths = all_xcodeproj_paths.reject { |p| p =~ /Pods|Carthage/ } path = xcodeproj_paths.first if xcodeproj_paths.count == 1 end loop do path = ask "Please enter the path to your Xcode project or use --xcodeproj: " if path.nil? # TODO: Allow the user to choose if xcodeproj_paths.count > 0 begin @xcodeproj = Xcodeproj::Project.open path return path rescue StandardError => e say e. end end end |