Class: Pod::Downloader::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods/downloader/request.rb

Overview

This class represents a download request for a given Pod.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(spec: nil, released: false, name: nil, params: false, head: false) ⇒ Request

Initialize a new instance

Parameters:

  • spec (Specification, Nil) (defaults to: nil)

    see #spec

  • released (Boolean) (defaults to: false)
  • name (String, Nil) (defaults to: nil)

    see #name

  • params (Hash<Symbol,String>, Nil) (defaults to: false)

    see #params

  • head (Boolean) (defaults to: false)

    see #head



48
49
50
51
52
53
54
55
56
# File 'lib/cocoapods/downloader/request.rb', line 48

def initialize(spec: nil, released: false, name: nil, params: false, head: false)
  @released_pod = released
  @spec = spec
  @params = spec ? (spec.source && spec.source.dup) : params
  @name = spec ? spec.name : name
  @head = head

  validate!
end

Instance Attribute Details

#headBoolean (readonly) Also known as: head?

Returns Whether the download request is for a head download.

Returns:

  • (Boolean)

    Whether the download request is for a head download.



28
29
30
# File 'lib/cocoapods/downloader/request.rb', line 28

def head
  @head
end

#nameString (readonly)

Returns The name of the pod whose dowload is being requested.

Returns:

  • (String)

    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

#paramsHash<Symbol, String> (readonly)

Returns The download parameters for this request.

Returns:

  • (Hash<Symbol, String>)

    The download parameters for this request.



24
25
26
# File 'lib/cocoapods/downloader/request.rb', line 24

def params
  @params
end

#released_podBoolean (readonly) Also known as: released_pod?

Returns Whether this download request is for a released pod.

Returns:

  • (Boolean)

    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

#specSpecification, Nil (readonly)

Returns The specification for the pod whose download is being requested.

Returns:

  • (Specification, Nil)

    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.

Parameters:

  • name (String) (defaults to: self.name)

    the name of the pod being downloaded.

  • params (Hash<#to_s, #to_s>) (defaults to: self.params)

    the download parameters of the pod being downloaded.

  • spec (Specification) (defaults to: self.spec)

    the specification of the pod being downloaded.

Returns:

  • (String)

    The slug used to store the files resulting from this download request.



70
71
72
73
74
75
76
77
78
79
# File 'lib/cocoapods/downloader/request.rb', line 70

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