Class: BranchIOCLI::Helper::BranchHelper
- Inherits:
-
Object
- Object
- BranchIOCLI::Helper::BranchHelper
- Extended by:
- AndroidHelper, IOSHelper
- Defined in:
- lib/branch_io_cli/helper/branch_helper.rb
Constant Summary
Constants included from IOSHelper
IOSHelper::APPLINKS, IOSHelper::ASSOCIATED_DOMAINS, IOSHelper::CODE_SIGN_ENTITLEMENTS, IOSHelper::DEVELOPMENT_TEAM, IOSHelper::PRODUCT_BUNDLE_IDENTIFIER, IOSHelper::RELEASE_CONFIGURATION
Class Attribute Summary collapse
-
.changes ⇒ Object
An array of file paths (Strings) that were modified.
-
.errors ⇒ Object
An array of error messages (Strings) from validation.
Class Method Summary collapse
- .add_change(change) ⇒ Object
- .download(url, dest) ⇒ Object
- .ensure_directory(path) ⇒ Object
- .fetch(url) ⇒ Object
Methods included from IOSHelper
add_branch_universal_link_domains_to_info_plist, add_carthage, add_cocoapods, add_direct, add_keys_to_info_plist, add_universal_links_to_project, app_ids_from_aasa_file, config, contents_of_aasa_file, domains_from_project, ensure_uri_scheme_in_info_plist, expanded_build_setting, has_multiple_info_plists?, target_from_project, team_and_bundle_from_app_id, update_cartfile, update_framework_search_paths, update_info_plist_setting, update_podfile, update_team_and_bundle_ids, update_team_and_bundle_ids_from_aasa_file, validate_project_domains, validate_team_and_bundle_ids, validate_team_and_bundle_ids_from_aasa_files, verify_carthage, verify_cocoapods, verify_git
Methods included from AndroidHelper
add_intent_filter_to_activity, add_intent_filters_to_android_manifest, add_keys_to_android_manifest, add_metadata_to_manifest, app_link_data_elements, find_activity, remove_existing_domains, uri_scheme_data_element
Class Attribute Details
.changes ⇒ Object
An array of file paths (Strings) that were modified
11 12 13 |
# File 'lib/branch_io_cli/helper/branch_helper.rb', line 11 def changes @changes end |
.errors ⇒ Object
An array of error messages (Strings) from validation
12 13 14 |
# File 'lib/branch_io_cli/helper/branch_helper.rb', line 12 def errors @errors end |
Class Method Details
.add_change(change) ⇒ Object
17 18 19 20 |
# File 'lib/branch_io_cli/helper/branch_helper.rb', line 17 def add_change(change) @changes ||= Set.new @changes << change.to_s end |
.download(url, dest) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/branch_io_cli/helper/branch_helper.rb', line 35 def download(url, dest) uri = URI(url) Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == "https") do |http| request = Net::HTTP::Get.new uri http.request request do |response| case response when Net::HTTPSuccess bytes_downloaded = 0 dots_reported = 0 # report a dot every 100 kB per_dot = 102_400 File.open dest, 'w' do |io| response.read_body do |chunk| io.write chunk # print progress bytes_downloaded += chunk.length while (bytes_downloaded - per_dot * dots_reported) >= per_dot print "." dots_reported += 1 end STDOUT.flush end end say "\n" when Net::HTTPRedirection download response['location'], dest else raise "Error downloading #{url}: #{response.code} #{response.}" end end end end |
.ensure_directory(path) ⇒ Object
72 73 74 75 76 77 78 |
# File 'lib/branch_io_cli/helper/branch_helper.rb', line 72 def ensure_directory(path) return if path == "/" || path == "." parent = File.dirname path ensure_directory parent return if Dir.exist? path Dir.mkdir path end |
.fetch(url) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/branch_io_cli/helper/branch_helper.rb', line 22 def fetch(url) response = Net::HTTP.get_response URI(url) case response when Net::HTTPSuccess response.body when Net::HTTPRedirection fetch response['location'] else raise "Error fetching #{url}: #{response.code} #{response.}" end end |