Class: Artifactory::GemImport::GemSpecs::Downloader

Inherits:
Object
  • Object
show all
Defined in:
lib/artifactory/gem_import/gem_specs/downloader.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url, headers) ⇒ Downloader

Returns a new instance of Downloader.



13
14
15
16
# File 'lib/artifactory/gem_import/gem_specs/downloader.rb', line 13

def initialize(url, headers)
  @url = url
  @headers = headers
end

Instance Attribute Details

#headersObject (readonly)

Returns the value of attribute headers.



11
12
13
# File 'lib/artifactory/gem_import/gem_specs/downloader.rb', line 11

def headers
  @headers
end

#urlObject (readonly)

Returns the value of attribute url.



11
12
13
# File 'lib/artifactory/gem_import/gem_specs/downloader.rb', line 11

def url
  @url
end

Class Method Details

.call(url, headers: {}) ⇒ Object



7
8
9
# File 'lib/artifactory/gem_import/gem_specs/downloader.rb', line 7

def self.call(url, headers: {})
  new(url, headers).call
end

Instance Method Details

#callObject



18
19
20
21
22
23
24
25
26
27
# File 'lib/artifactory/gem_import/gem_specs/downloader.rb', line 18

def call
  response = HTTParty.get url,
                          headers: headers

  if response.success?
    response.body
  else
    response.error!
  end
end