Class: Bundler::Fetcher::CompactIndex
Relationships & Source Files | |
Namespace Children | |
Classes:
| |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
Base
|
|
Instance Chain:
self,
Base
|
|
Inherits: |
Bundler::Fetcher::Base
|
Defined in: | lib/bundler/fetcher/compact_index.rb |
Class Method Summary
Instance Attribute Summary
- #api_fetcher? ⇒ Boolean readonly
- #available? ⇒ Boolean readonly
Base
- Inherited
Instance Method Summary
- #fetch_spec(spec)
- #specs(gem_names)
- #specs_for_names(gem_names)
- #bundle_worker(func = nil) private
- #cache_path private
- #client_fetcher private
- #compact_index_client private
- #parallel_compact_index_client private
- #serial_compact_index_client private
Base
- Inherited
Constructor Details
This class inherits a constructor from Bundler::Fetcher::Base
Class Method Details
.compact_index_request(method_name)
[ GitHub ]# File 'lib/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. rescue AuthenticationRequiredError # Fail since we got a 401 from the server. raise rescue HTTPError => e Bundler.ui.trace(e) nil end end end
Instance Attribute Details
#api_fetcher? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'lib/bundler/fetcher/compact_index.rb', line 82
def api_fetcher? true end
#available? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'lib/bundler/fetcher/compact_index.rb', line 70
def available? return nil unless SharedHelpers.md5_available? user_home = Bundler.user_home return nil unless user_home.directory? && user_home.writable? # Read info file checksums out of /versions, so we can know if gems are up to date fetch_uri.scheme != "file" && compact_index_client.update_and_parse_checksums! rescue CompactIndexClient::Updater::MisMatchedChecksumError => e Bundler.ui.debug(e. ) nil end
Instance Method Details
#bundle_worker(func = nil) (private)
[ GitHub ]# File 'lib/bundler/fetcher/compact_index.rb', line 111
def bundle_worker(func = nil) @bundle_worker ||= begin worker_name = "Compact Index (#{display_uri.host})" Bundler::Worker.new(Bundler.current_ruby.rbx? ? 1 : 25, worker_name, func) end @bundle_worker.tap do |worker| worker.instance_variable_set(:@func, func) if func end end
#cache_path (private)
[ GitHub ]# File 'lib/bundler/fetcher/compact_index.rb', line 121
def cache_path Bundler.user_cache.join("compact_index", remote.cache_slug) end
#client_fetcher (private)
[ GitHub ]# File 'lib/bundler/fetcher/compact_index.rb', line 125
def client_fetcher ClientFetcher.new(self, Bundler.ui) end
#compact_index_client (private)
[ GitHub ]# File 'lib/bundler/fetcher/compact_index.rb', line 88
def compact_index_client @compact_index_client ||= SharedHelpers.filesystem_access(cache_path) do CompactIndexClient.new(cache_path, client_fetcher) end end
#fetch_spec(spec)
[ GitHub ]# File 'lib/bundler/fetcher/compact_index.rb', line 60
def fetch_spec(spec) spec -= [nil, "ruby", ""] contents = compact_index_client.spec(*spec) return nil if contents.nil? contents.unshift(spec.first) contents[3].map! {|d| Gem::Dependency.new(*d) } EndpointSpecification.new(*contents) end
#parallel_compact_index_client (private)
[ GitHub ]# File 'lib/bundler/fetcher/compact_index.rb', line 95
def parallel_compact_index_client compact_index_client.execution_mode = lambda do |inputs, &blk| func = lambda {|object, _index| blk.call(object) } worker = bundle_worker(func) inputs.each {|input| worker.enq(input) } inputs.map { worker.deq } end compact_index_client end
#serial_compact_index_client (private)
[ GitHub ]# File 'lib/bundler/fetcher/compact_index.rb', line 106
def serial_compact_index_client compact_index_client.sequential_execution_mode! compact_index_client end
#specs(gem_names)
[ GitHub ]# File 'lib/bundler/fetcher/compact_index.rb', line 29
def specs(gem_names) specs_for_names(gem_names) end
#specs_for_names(gem_names)
[ GitHub ]# File 'lib/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