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/updater.rb |
Constant Summary
-
DEBUG_MUTEX =
# File 'lib/bundler/compact_index_client.rb', line 8Mutex.new
Class Method Summary
- .debug
- .new(directory, fetcher) ⇒ CompactIndexClient constructor
Instance Attribute Summary
- #directory readonly
- #in_parallel ⇒ Lambda rw
Instance Method Summary
Constructor Details
.new(directory, fetcher) ⇒ CompactIndexClient
# File 'lib/bundler/compact_index_client.rb', line 26
def initialize(directory, fetcher) @directory = Pathname.new(directory) @updater = Updater.new(fetcher) @cache = Cache.new(@directory) @endpoints = Set.new @info_checksums_by_name = {} @parsed_checksums = false @mutex = Mutex.new @in_parallel = lambda do |inputs, &blk| inputs.map(&blk) end end
Class Method Details
.debug
[ GitHub ]# File 'lib/bundler/compact_index_client.rb', line 9
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 19
attr_reader :directory
#in_parallel ⇒ Lambda
(rw)
# File 'lib/bundler/compact_index_client.rb', line 24
attr_accessor :in_parallel
Instance Method Details
#dependencies(names)
[ GitHub ]# File 'lib/bundler/compact_index_client.rb', line 52
def dependencies(names) Bundler::CompactIndexClient.debug { "dependencies(#{names})" } in_parallel.call(names) do |name| update_info(name) @cache.dependencies(name).map {|d| d.unshift(name) } end.flatten(1) end
#names
[ GitHub ]#spec(name, version, platform = nil)
[ GitHub ]# File 'lib/bundler/compact_index_client.rb', line 60
def spec(name, version, platform = nil) Bundler::CompactIndexClient.debug { "spec(name = #{name}, version = #{version}, platform = #{platform})" } update_info(name) @cache.specific_dependency(name, version, platform) end
#synchronize (private)
[ GitHub ]# File 'lib/bundler/compact_index_client.rb', line 105
def synchronize @mutex.synchronize { yield } end
#update(local_path, remote_path) (private)
[ GitHub ]# File 'lib/bundler/compact_index_client.rb', line 76
def update(local_path, remote_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(local_path, url(remote_path)) end
#update_and_parse_checksums!
[ GitHub ]# File 'lib/bundler/compact_index_client.rb', line 66
def update_and_parse_checksums! Bundler::CompactIndexClient.debug { "update_and_parse_checksums!" } return @info_checksums_by_name if @parsed_checksums update(@cache.versions_path, "versions") @info_checksums_by_name = @cache.checksums @parsed_checksums = true end
#update_info(name) (private)
[ GitHub ]# File 'lib/bundler/compact_index_client.rb', line 85
def update_info(name) Bundler::CompactIndexClient.debug { "update_info(#{name})" } path = @cache.info_path(name) checksum = @updater.checksum_for_file(path) unless existing = @info_checksums_by_name[name] Bundler::CompactIndexClient.debug { "skipping updating info for #{name} since it is missing from versions" } return end 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(path, "info/#{name}") end
#url(path) (private)
[ GitHub ]# File 'lib/bundler/compact_index_client.rb', line 101
def url(path) path end