Class: Pod::ExternalSources::AbstractExternalSource
- Inherits:
-
Object
- Object
- Pod::ExternalSources::AbstractExternalSource
- Defined in:
- lib/cocoapods/external_sources/abstract_external_source.rb
Overview
Abstract class that defines the common behaviour of external sources.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#can_cache ⇒ Boolean
(also: #can_cache?)
readonly
Whether the source is allowed to touch the cache.
-
#name ⇒ String
readonly
The name of the Pod described by this external source.
-
#params ⇒ Hash{Symbol => String}
readonly
The hash representation of the external source.
-
#podfile_path ⇒ String
readonly
The path where the podfile is defined to resolve relative paths.
Subclasses hooks collapse
-
#description ⇒ String
A string representation of the source suitable for UI.
- #download_request ⇒ Object private
-
#fetch(_sandbox) ⇒ void
Fetches the external source from the remote according to the params.
-
#pre_download(sandbox) ⇒ void
private
Pre-downloads a Pod passing the options to the downloader and informing the sandbox.
-
#store_podspec(sandbox, spec, json = false) ⇒ void
private
Stores the podspec in the sandbox and marks it as from an external source.
- #validate_podspec(podspec) ⇒ Object private
- #validator_for_podspec(podspec) ⇒ Object private
Instance Method Summary collapse
- #==(other) ⇒ Boolean
-
#initialize(name, params, podfile_path, can_cache = true) ⇒ AbstractExternalSource
constructor
Initialize a new instance.
Constructor Details
#initialize(name, params, podfile_path, can_cache = true) ⇒ AbstractExternalSource
Initialize a new instance
32 33 34 35 36 37 |
# File 'lib/cocoapods/external_sources/abstract_external_source.rb', line 32 def initialize(name, params, podfile_path, can_cache = true) @name = name @params = params @podfile_path = podfile_path @can_cache = can_cache end |
Instance Attribute Details
#can_cache ⇒ Boolean (readonly) Also known as: can_cache?
Returns Whether the source is allowed to touch the cache.
22 23 24 |
# File 'lib/cocoapods/external_sources/abstract_external_source.rb', line 22 def can_cache @can_cache end |
#name ⇒ String (readonly)
Returns the name of the Pod described by this external source.
8 9 10 |
# File 'lib/cocoapods/external_sources/abstract_external_source.rb', line 8 def name @name end |
#params ⇒ Hash{Symbol => String} (readonly)
Returns the hash representation of the external source.
13 14 15 |
# File 'lib/cocoapods/external_sources/abstract_external_source.rb', line 13 def params @params end |
#podfile_path ⇒ String (readonly)
Returns the path where the podfile is defined to resolve relative paths.
18 19 20 |
# File 'lib/cocoapods/external_sources/abstract_external_source.rb', line 18 def podfile_path @podfile_path end |
Instance Method Details
#==(other) ⇒ Boolean
42 43 44 45 |
# File 'lib/cocoapods/external_sources/abstract_external_source.rb', line 42 def ==(other) return false if other.nil? name == other.name && params == other.params end |
#description ⇒ String
Returns a string representation of the source suitable for UI.
64 65 66 |
# File 'lib/cocoapods/external_sources/abstract_external_source.rb', line 64 def description raise 'Abstract method' end |
#download_request ⇒ Object (private)
136 137 138 139 140 141 |
# File 'lib/cocoapods/external_sources/abstract_external_source.rb', line 136 def download_request Downloader::Request.new( :name => name, :params => params, ) end |
#fetch(_sandbox) ⇒ void
This method returns an undefined value.
Fetches the external source from the remote according to the params.
58 59 60 |
# File 'lib/cocoapods/external_sources/abstract_external_source.rb', line 58 def fetch(_sandbox) raise 'Abstract method' end |
#pre_download(sandbox) ⇒ void (private)
The downloader configuration is the same of the
PodSourceInstaller and it needs to be kept in sync.
To prevent a double download of the repository the pod is marked as pre-downloaded indicating to the installer that only clean operations are needed.
This method returns an undefined value.
Pre-downloads a Pod passing the options to the downloader and informing the sandbox.
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/cocoapods/external_sources/abstract_external_source.rb', line 111 def pre_download(sandbox) title = "Pre-downloading: `#{name}` #{description}" UI.titled_section(title, :verbose_prefix => '-> ') do target = sandbox.pod_dir(name) begin download_result = Downloader.download(download_request, target, :can_cache => can_cache) rescue Pod::DSLError => e raise Informative, "Failed to load '#{name}' podspec: #{e.}" rescue => e raise Informative, "Failed to download '#{name}': #{e.}" end spec = download_result.spec raise Informative, "Unable to find a specification for '#{name}'." unless spec # since the podspec might be cleaned, we want the checksum to refer # to the json in the sandbox spec.defined_in_file = nil store_podspec(sandbox, spec) sandbox.store_pre_downloaded_pod(name) sandbox.store_checkout_source(name, download_result.) end end |
#store_podspec(sandbox, spec, json = false) ⇒ void (private)
All the concrete implementations of ##fetch should invoke this method.
The sandbox ensures that the podspec exists and that the names match.
This method returns an undefined value.
Stores the podspec in the sandbox and marks it as from an external source.
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 |
# File 'lib/cocoapods/external_sources/abstract_external_source.rb', line 160 def store_podspec(sandbox, spec, json = false) begin spec = case spec when Pathname Specification.from_file(spec) when String path = "#{name}.podspec" path << '.json' if json Specification.from_string(spec, path).tap { |s| s.defined_in_file = nil } when Specification spec.dup else raise "Unknown spec type: #{spec}" end rescue Pod::DSLError => e raise Informative, "Failed to load '#{name}' podspec: #{e.}" end validate_podspec(spec) sandbox.store_podspec(name, spec, true, true) end |
#validate_podspec(podspec) ⇒ Object (private)
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 |
# File 'lib/cocoapods/external_sources/abstract_external_source.rb', line 182 def validate_podspec(podspec) defined_in_file = podspec.defined_in_file podspec.defined_in_file = nil validator = validator_for_podspec(podspec) validator.quick = true validator.allow_warnings = true validator.ignore_public_only_results = true Config.instance.with_changes(:silent => true) do validator.validate end unless validator.validated? raise Informative, "The `#{name}` pod failed to validate due to #{validator.failure_reason}:\n#{validator.}" end ensure podspec.defined_in_file = defined_in_file end |