class Bundler::Fetcher::CompactIndex

Constants

ClientFetcher

Public Class Methods

compact_index_request(method_name) click to toggle source
# File bundler/fetcher/compact_index.rb, line 11
def self.compact_index_request(method_name)
  method = instance_method(method_name)
  undef_method(method_name)
  define_method(method_name) do |*args, &blk|
    begin
      method.bind(self).call(*args, &blk)
    rescue NetworkDownError, CompactIndexClient::Updater::MisMatchedChecksumError => e
      raise HTTPError, e.message
    rescue AuthenticationRequiredError
      # Fail since we got a 401 from the server.
      raise
    rescue HTTPError => e
      Bundler.ui.trace(e)
      nil
    end
  end
end

Public Instance Methods

api_fetcher?() click to toggle source
# File bundler/fetcher/compact_index.rb, line 77
def api_fetcher?
  true
end
available?() click to toggle source
# File bundler/fetcher/compact_index.rb, line 60
def available?
  unless SharedHelpers.md5_available?
    Bundler.ui.debug("FIPS mode is enabled, bundler can't use the CompactIndex API")
    return nil
  end
  if fetch_uri.scheme == "file"
    Bundler.ui.debug("Using a local server, bundler won't use the CompactIndex API")
    return false
  end
  # Read info file checksums out of /versions, so we can know if gems are up to date
  compact_index_client.update_and_parse_checksums!
rescue CompactIndexClient::Updater::MisMatchedChecksumError => e
  Bundler.ui.debug(e.message)
  nil
end
specs(gem_names) click to toggle source
# File bundler/fetcher/compact_index.rb, line 29
def specs(gem_names)
  specs_for_names(gem_names)
end
specs_for_names(gem_names) click to toggle source
# File bundler/fetcher/compact_index.rb, line 34
def specs_for_names(gem_names)
  gem_info = []
  complete_gems = []
  remaining_gems = gem_names.dup

  until remaining_gems.empty?
    log_specs "Looking up gems #{remaining_gems.inspect}"

    deps = begin
             parallel_compact_index_client.dependencies(remaining_gems)
           rescue TooManyRequestsError
             @bundle_worker.stop if @bundle_worker
             @bundle_worker = nil # reset it.  Not sure if necessary
             serial_compact_index_client.dependencies(remaining_gems)
           end
    next_gems = deps.map {|d| d[3].map(&:first).flatten(1) }.flatten(1).uniq
    deps.each {|dep| gem_info << dep }
    complete_gems.concat(deps.map(&:first)).uniq!
    remaining_gems = next_gems - complete_gems
  end
  @bundle_worker.stop if @bundle_worker
  @bundle_worker = nil # reset it.  Not sure if necessary

  gem_info
end