Class: Pod::Installer::PodSourceDownloader
- Inherits:
-
Object
- Object
- Pod::Installer::PodSourceDownloader
- Defined in:
- lib/cocoapods/installer/pod_source_downloader.rb
Overview
This class needs to consider all the activated specs of a Pod.
Controller class responsible for downloading the activated specifications of a single Pod.
Constant Summary collapse
- UNENCRYPTED_PROTOCOLS =
%w(http git).freeze
Instance Attribute Summary collapse
-
#can_cache ⇒ Boolean
(also: #can_cache?)
readonly
Whether the installer is allowed to touch the cache.
-
#podfile ⇒ Podfile
readonly
The podfile that should be integrated with the user projects.
-
#sandbox ⇒ Sandbox
readonly
The installation target.
-
#specs_by_platform ⇒ Hash{Symbol=>Array}
readonly
The specifications that need to be installed grouped by platform.
Downloading collapse
-
#download! ⇒ void
Creates the target in the Pods project and the relative support files.
Download Steps collapse
- #download_request ⇒ Object private
-
#verify_source_is_secure(root_spec) ⇒ void
private
Verify the source of the spec is secure, which is used to show a warning to the user if that isn't the case This method doesn't verify all protocols, but currently only prohibits unencrypted 'http://' and 'git://'' connections.
Convenience methods. collapse
-
#local? ⇒ Boolean
private
Whether the pod uses the local option and thus CocoaPods should not interfere with the files of the user.
-
#predownloaded? ⇒ Boolean
private
Whether the source has been pre downloaded in the resolution process to retrieve its podspec.
- #released? ⇒ Boolean private
-
#root ⇒ Pathname
private
The folder where the source of the Pod is located.
-
#root_spec ⇒ Specification
private
The root specification of the Pod.
-
#specs ⇒ Array<Specifications>
private
The specification of the Pod used in this installation.
Instance Method Summary collapse
-
#initialize(sandbox, podfile, specs_by_platform, can_cache: true) ⇒ PodSourceDownloader
constructor
Initialize a new instance.
-
#inspect ⇒ String
A string suitable for debugging.
-
#name ⇒ String
The name of the pod this downloader is downloading.
Constructor Details
#initialize(sandbox, podfile, specs_by_platform, can_cache: true) ⇒ PodSourceDownloader
Initialize a new instance
38 39 40 41 42 43 |
# File 'lib/cocoapods/installer/pod_source_downloader.rb', line 38 def initialize(sandbox, podfile, specs_by_platform, can_cache: true) @sandbox = sandbox @podfile = podfile @specs_by_platform = specs_by_platform @can_cache = can_cache end |
Instance Attribute Details
#can_cache ⇒ Boolean (readonly) Also known as: can_cache?
Returns Whether the installer is allowed to touch the cache.
28 29 30 |
# File 'lib/cocoapods/installer/pod_source_downloader.rb', line 28 def can_cache @can_cache end |
#podfile ⇒ Podfile (readonly)
Returns the podfile that should be integrated with the user projects.
19 20 21 |
# File 'lib/cocoapods/installer/pod_source_downloader.rb', line 19 def podfile @podfile end |
#sandbox ⇒ Sandbox (readonly)
Returns The installation target.
14 15 16 |
# File 'lib/cocoapods/installer/pod_source_downloader.rb', line 14 def sandbox @sandbox end |
#specs_by_platform ⇒ Hash{Symbol=>Array} (readonly)
Returns The specifications that need to be installed grouped by platform.
24 25 26 |
# File 'lib/cocoapods/installer/pod_source_downloader.rb', line 24 def specs_by_platform @specs_by_platform end |
Instance Method Details
#download! ⇒ void
This method returns an undefined value.
Creates the target in the Pods project and the relative support files.
67 68 69 70 71 72 73 74 75 76 |
# File 'lib/cocoapods/installer/pod_source_downloader.rb', line 67 def download! verify_source_is_secure(root_spec) download_result = Downloader.download(download_request, root, :can_cache => can_cache?) if (specific_source = download_result.) && specific_source != root_spec.source sandbox.store_checkout_source(root_spec.name, specific_source) end sandbox.store_downloaded_pod(root_spec.name) end |
#download_request ⇒ Object (private)
106 107 108 109 110 111 |
# File 'lib/cocoapods/installer/pod_source_downloader.rb', line 106 def download_request Downloader::Request.new( :spec => root_spec, :released => released?, ) end |
#inspect ⇒ String
Returns A string suitable for debugging.
47 48 49 |
# File 'lib/cocoapods/installer/pod_source_downloader.rb', line 47 def inspect "<#{self.class} sandbox=#{sandbox.root} pod=#{root_spec.name}" end |
#local? ⇒ Boolean (private)
Returns whether the pod uses the local option and thus CocoaPods should not interfere with the files of the user.
148 149 150 |
# File 'lib/cocoapods/installer/pod_source_downloader.rb', line 148 def local? sandbox.local?(root_spec.name) end |
#name ⇒ String
Returns The name of the pod this downloader is downloading.
53 54 55 |
# File 'lib/cocoapods/installer/pod_source_downloader.rb', line 53 def name root_spec.name end |
#predownloaded? ⇒ Boolean (private)
Returns whether the source has been pre downloaded in the resolution process to retrieve its podspec.
141 142 143 |
# File 'lib/cocoapods/installer/pod_source_downloader.rb', line 141 def predownloaded? sandbox.predownloaded_pods.include?(root_spec.name) end |
#released? ⇒ Boolean (private)
152 153 154 |
# File 'lib/cocoapods/installer/pod_source_downloader.rb', line 152 def released? sandbox.specification(root_spec.name) != root_spec end |
#root ⇒ Pathname (private)
Returns the folder where the source of the Pod is located.
134 135 136 |
# File 'lib/cocoapods/installer/pod_source_downloader.rb', line 134 def root sandbox.pod_dir(root_spec.name) end |
#root_spec ⇒ Specification (private)
Returns the root specification of the Pod.
128 129 130 |
# File 'lib/cocoapods/installer/pod_source_downloader.rb', line 128 def root_spec specs.first.root end |
#specs ⇒ Array<Specifications> (private)
Returns the specification of the Pod used in this installation.
122 123 124 |
# File 'lib/cocoapods/installer/pod_source_downloader.rb', line 122 def specs specs_by_platform.values.flatten end |
#verify_source_is_secure(root_spec) ⇒ void (private)
This method returns an undefined value.
Verify the source of the spec is secure, which is used to show a warning to the user if that isn't the case This method doesn't verify all protocols, but currently only prohibits unencrypted 'http://' and 'git://'' connections.
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/cocoapods/installer/pod_source_downloader.rb', line 90 def verify_source_is_secure(root_spec) return if root_spec.source.nil? || (root_spec.source[:http].nil? && root_spec.source[:git].nil?) source = if !root_spec.source[:http].nil? URI(root_spec.source[:http].to_s) elsif !root_spec.source[:git].nil? git_source = root_spec.source[:git].to_s return unless git_source =~ /^#{URI::DEFAULT_PARSER.make_regexp}$/ URI(git_source) end if UNENCRYPTED_PROTOCOLS.include?(source.scheme) && source.host != 'localhost' UI.warn "'#{root_spec.name}' uses the unencrypted '#{source.scheme}' protocol to transfer the Pod. " \ 'Please be sure you\'re in a safe network with only trusted hosts. ' \ 'Otherwise, please reach out to the library author to notify them of this security issue.' end end |