Class: LibyearRb::GemInfoFetcher

Inherits:
Object
  • Object
show all
Defined in:
lib/libyear_rb/gem_info_fetcher.rb

Instance Method Summary collapse

Constructor Details

#initialize(remote_host, rate_limiter: -> {}) ⇒ GemInfoFetcher

Returns a new instance of GemInfoFetcher.



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/libyear_rb/gem_info_fetcher.rb', line 9

def initialize(remote_host, rate_limiter: -> {})
  @remote_host = remote_host
  @rate_limiter = rate_limiter
  source = Gem.sources.each_source.find { |s| s.uri.host == remote_host }
  if source
    uri = source.uri
    @client = Gems::Client.new(
      host: uri.origin + uri.request_uri,
      username: uri.user,
      password: uri.password
    )
  end
end

Instance Method Details

#versions_for(gem_name) ⇒ Object



23
24
25
26
27
28
# File 'lib/libyear_rb/gem_info_fetcher.rb', line 23

def versions_for(gem_name)
  return [] unless @client

  raw = fetch_raw(gem_name)
  parse_versions(gem_name, raw)
end