Class: Pod::Downloader::Request
- Inherits:
-
Object
- Object
- Pod::Downloader::Request
- Defined in:
- lib/cocoapods/downloader/request.rb
Overview
This class represents a download request for a given Pod.
Instance Attribute Summary collapse
-
#name ⇒ String
readonly
The name of the pod whose dowload is being requested.
-
#params ⇒ Hash<Symbol, String>
readonly
The download parameters for this request.
-
#released_pod ⇒ Boolean
(also: #released_pod?)
readonly
Whether this download request is for a released pod.
-
#spec ⇒ Specification, Nil
readonly
The specification for the pod whose download is being requested.
Instance Method Summary collapse
-
#initialize(spec: nil, released: false, name: nil, params: false) ⇒ Request
constructor
Initialize a new instance.
-
#slug(name: self.name, params: self.params, spec: self.spec) ⇒ String
The slug used to store the files resulting from this download request.
-
#validate! ⇒ Void
private
Validates that the given request is well-formed.
Constructor Details
#initialize(spec: nil, released: false, name: nil, params: false) ⇒ Request
Initialize a new instance
40 41 42 43 44 45 46 47 |
# File 'lib/cocoapods/downloader/request.rb', line 40 def initialize(spec: nil, released: false, name: nil, params: false) @released_pod = released @spec = spec @params = spec ? (spec.source && spec.source.dup) : params @name = spec ? spec.name : name validate! end |
Instance Attribute Details
#name ⇒ String (readonly)
Returns The name of the pod whose dowload is being requested.
20 21 22 |
# File 'lib/cocoapods/downloader/request.rb', line 20 def name @name end |
#params ⇒ Hash<Symbol, String> (readonly)
Returns The download parameters for this request.
24 25 26 |
# File 'lib/cocoapods/downloader/request.rb', line 24 def params @params end |
#released_pod ⇒ Boolean (readonly) Also known as: released_pod?
Returns Whether this download request is for a released pod.
15 16 17 |
# File 'lib/cocoapods/downloader/request.rb', line 15 def released_pod @released_pod end |
#spec ⇒ Specification, Nil (readonly)
Returns The specification for the pod whose download is being requested.
11 12 13 |
# File 'lib/cocoapods/downloader/request.rb', line 11 def spec @spec end |
Instance Method Details
#slug(name: self.name, params: self.params, spec: self.spec) ⇒ String
Returns The slug used to store the files resulting from this download request.
61 62 63 64 65 66 67 68 69 70 |
# File 'lib/cocoapods/downloader/request.rb', line 61 def slug(name: self.name, params: self.params, spec: self.spec) checksum = spec && spec.checksum && '-' << spec.checksum[0, 5] if released_pod? "Release/#{name}/#{spec.version}#{checksum}" else opts = params.to_a.sort_by(&:first).map { |k, v| "#{k}=#{v}" }.join('-') digest = Digest::MD5.hexdigest(opts) "External/#{name}/#{digest}#{checksum}" end end |
#validate! ⇒ Void (private)
Validates that the given request is well-formed.
78 79 80 81 82 83 |
# File 'lib/cocoapods/downloader/request.rb', line 78 def validate! raise ArgumentError, 'Requires a name' unless name raise ArgumentError, 'Must give a spec for a released download request' if released_pod? && !spec raise ArgumentError, 'Requires a version if released' if released_pod? && !spec.version raise ArgumentError, 'Requires params' unless params end |