Class: Gemstash::GemFetcher

Inherits:
Object
  • Object
show all
Defined in:
lib/gemstash/gem_fetcher.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(http_client) ⇒ GemFetcher

Returns a new instance of GemFetcher.



9
10
11
12
# File 'lib/gemstash/gem_fetcher.rb', line 9

def initialize(http_client)
  @http_client = http_client
  @valid_headers = Set.new(%w[etag content-type content-length last-modified])
end

Instance Method Details

#fetch(gem_id, type, &block) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/gemstash/gem_fetcher.rb', line 14

def fetch(gem_id, type, &block)
  @http_client.get(path_for(gem_id, type)) do |body, headers|
    properties = filter_headers(headers)
    validate_download(body, properties)
    yield body, properties
  end
end