Class: Bundler::CompactIndexClient
Relationships & Source Files | |
Namespace Children | |
Classes:
| |
Exceptions:
| |
Inherits: | Object |
Defined in: | lib/bundler/compact_index_client.rb, lib/bundler/compact_index_client/cache.rb, lib/bundler/compact_index_client/cache_file.rb, lib/bundler/compact_index_client/gem_parser.rb, lib/bundler/compact_index_client/updater.rb |
Constant Summary
-
DEBUG_MUTEX =
# File 'lib/bundler/compact_index_client.rb', line 13Thread::Mutex.new
-
SUPPORTED_DIGESTS =
NOTE: MD5 is here not because we expect a server to respond with it, but because we use it to generate the etag on first request during the upgrade to the compact index client that uses opaque etags saved to files. Remove once 2.5.0 has been out for a while.
{ "sha-256" => :SHA256, "md5" => :MD5 }.freeze
Class Method Summary
- .debug
- .new(directory, fetcher) ⇒ CompactIndexClient constructor
Instance Attribute Summary
- #directory readonly
- #execution_mode ⇒ Lambda rw
- #execution_mode=(block) rw
Instance Method Summary
Constructor Details
.new(directory, fetcher) ⇒ CompactIndexClient
Class Method Details
.debug
[ GitHub ]# File 'lib/bundler/compact_index_client.rb', line 15
def self.debug return unless ENV["DEBUG_COMPACT_INDEX"] DEBUG_MUTEX.synchronize { warn("[#{self}] #{yield}") } end
Instance Attribute Details
#directory (readonly)
[ GitHub ]# File 'lib/bundler/compact_index_client.rb', line 26
attr_reader :directory
#execution_mode ⇒ Lambda
(rw)
# File 'lib/bundler/compact_index_client.rb', line 48
def execution_mode @execution_mode || sequentially end
#execution_mode=(block) (rw)
[ GitHub ]Instance Method Details
#dependencies(names)
[ GitHub ]# File 'lib/bundler/compact_index_client.rb', line 75
def dependencies(names) Bundler::CompactIndexClient.debug { "dependencies(#{names})" } execution_mode.call(names) do |name| update_info(name) @cache.dependencies(name).map {|d| d.unshift(name) } end.flatten(1) end
#names
[ GitHub ]#sequential_execution_mode!
[ GitHub ]# File 'lib/bundler/compact_index_client.rb', line 52
def sequential_execution_mode! self.execution_mode = sequentially end
#sequentially
[ GitHub ]# File 'lib/bundler/compact_index_client.rb', line 56
def sequentially @sequentially ||= lambda do |inputs, &blk| inputs.map(&blk) end end
#synchronize (private)
[ GitHub ]# File 'lib/bundler/compact_index_client.rb', line 122
def synchronize @mutex.synchronize { yield } end
#update(remote_path, local_path, local_etag_path) (private)
[ GitHub ]# File 'lib/bundler/compact_index_client.rb', line 93
def update(remote_path, local_path, local_etag_path) Bundler::CompactIndexClient.debug { "update(#{local_path}, #{remote_path})" } unless synchronize { @endpoints.add?(remote_path) } Bundler::CompactIndexClient.debug { "already fetched #{remote_path}" } return end @updater.update(url(remote_path), local_path, local_etag_path) end
#update_and_parse_checksums!
[ GitHub ]# File 'lib/bundler/compact_index_client.rb', line 83
def update_and_parse_checksums! Bundler::CompactIndexClient.debug { "update_and_parse_checksums!" } return @info_checksums_by_name if @parsed_checksums update("versions", @cache.versions_path, @cache.versions_etag_path) @info_checksums_by_name = @cache.checksums @parsed_checksums = true end
#update_info(name) (private)
[ GitHub ]# File 'lib/bundler/compact_index_client.rb', line 102
def update_info(name) Bundler::CompactIndexClient.debug { "update_info(#{name})" } path = @cache.info_path(name) unless existing = @info_checksums_by_name[name] Bundler::CompactIndexClient.debug { "skipping updating info for #{name} since it is missing from versions" } return end checksum = SharedHelpers.checksum_for_file(path, :MD5) if checksum == existing Bundler::CompactIndexClient.debug { "skipping updating info for #{name} since the versions checksum matches the local checksum" } return end Bundler::CompactIndexClient.debug { "updating info for #{name} since the versions checksum #{existing} != the local checksum #{checksum}" } update("info/#{name}", path, @cache.info_etag_path(name)) end
#url(path) (private)
[ GitHub ]# File 'lib/bundler/compact_index_client.rb', line 118
def url(path) path end