Class: Bundler::Fetcher::CompactIndex

Inherits:
Base
  • Object
show all
Defined in:
lib/bundler/fetcher/compact_index.rb

Defined Under Namespace

Classes: ClientFetcher

Instance Attribute Summary

Attributes inherited from Base

#display_uri, #downloader, #gem_remote_fetcher, #remote

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#fetch_uri, #initialize, #remote_uri

Constructor Details

This class inherits a constructor from Bundler::Fetcher::Base

Class Method Details

.compact_index_request(method_name) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/bundler/fetcher/compact_index.rb', line 9

def self.compact_index_request(method_name)
  method = instance_method(method_name)
  undef_method(method_name)
  define_method(method_name) do |*args, &blk|
    method.bind_call(self, *args, &blk)
  rescue NetworkDownError, CompactIndexClient::Updater::MismatchedChecksumError => e
    raise HTTPError, e.message
  rescue AuthenticationRequiredError, BadAuthenticationError
    # Fail since we got a 401 from the server.
    raise
  rescue HTTPError => e
    Bundler.ui.trace(e)
    nil
  end
end

Instance Method Details

#api_fetcher?Boolean

Returns:

  • (Boolean)


62
63
64
# File 'lib/bundler/fetcher/compact_index.rb', line 62

def api_fetcher?
  true
end

#available?Boolean

Returns:

  • (Boolean)


49
50
51
52
53
54
55
56
57
58
59
# File 'lib/bundler/fetcher/compact_index.rb', line 49

def available?
  unless SharedHelpers.md5_available?
    Bundler.ui.debug("FIPS mode is enabled, bundler can't use the CompactIndex API")
    return nil
  end
  # Read info file checksums out of /versions, so we can know if gems are up to date
  compact_index_client.available?
rescue CompactIndexClient::Updater::MismatchedChecksumError => e
  Bundler.ui.debug(e.message)
  nil
end

#specs(gem_names) ⇒ Object



25
26
27
# File 'lib/bundler/fetcher/compact_index.rb', line 25

def specs(gem_names)
  specs_for_names(gem_names)
end

#specs_for_names(gem_names) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/bundler/fetcher/compact_index.rb', line 30

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 = fetch_gem_infos(remaining_gems).flatten(1)
    next_gems = deps.flat_map {|d| d[CompactIndexClient::INFO_DEPS].flat_map(&:first) }.uniq
    deps.each {|dep| gem_info << dep }
    complete_gems.concat(deps.map(&:first)).uniq!
    remaining_gems = next_gems - complete_gems
  end
  @bundle_worker&.stop
  @bundle_worker = nil # reset it.  Not sure if necessary

  gem_info
end