class Bundler::CompactIndexClient

frozen_string_literal: true

Constants

VERSION

Attributes

directory[R]
in_parallel[RW]

@return [Lambda] A lambda that takes an array of inputs and a block, and

maps the inputs with the block in parallel.

Public Class Methods

new(directory, fetcher) click to toggle source
# File lib/bundler/vendor/compact_index_client/lib/compact_index_client.rb, line 19
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
  @in_parallel = lambda do |inputs, &blk|
    inputs.map(&blk)
  end
end

Public Instance Methods

dependencies(names) click to toggle source
# File lib/bundler/vendor/compact_index_client/lib/compact_index_client.rb, line 42
def dependencies(names)
  in_parallel.call(names) do |name|
    update_info(name)
    @cache.dependencies(name).map {|d| d.unshift(name) }
  end.flatten(1)
end
names() click to toggle source
# File lib/bundler/vendor/compact_index_client/lib/compact_index_client.rb, line 31
def names
  update(@cache.names_path, "names")
  @cache.names
end
spec(name, version, platform = nil) click to toggle source
# File lib/bundler/vendor/compact_index_client/lib/compact_index_client.rb, line 49
def spec(name, version, platform = nil)
  update_info(name)
  @cache.specific_dependency(name, version, platform)
end
update_and_parse_checksums!() click to toggle source
# File lib/bundler/vendor/compact_index_client/lib/compact_index_client.rb, line 54
def 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
versions() click to toggle source
# File lib/bundler/vendor/compact_index_client/lib/compact_index_client.rb, line 36
def versions
  update(@cache.versions_path, "versions")
  versions, @info_checksums_by_name = @cache.versions
  versions
end

Private Instance Methods

update(local_path, remote_path) click to toggle source
# File lib/bundler/vendor/compact_index_client/lib/compact_index_client.rb, line 63
def update(local_path, remote_path)
  return unless @endpoints.add?(remote_path)
  @updater.update(local_path, url(remote_path))
end
update_info(name) click to toggle source
# File lib/bundler/vendor/compact_index_client/lib/compact_index_client.rb, line 68
def update_info(name)
  path = @cache.info_path(name)
  checksum = @updater.checksum_for_file(path)
  return unless existing = @info_checksums_by_name[name]
  return if checksum == existing
  update(path, "info/#{name}")
end
url(path) click to toggle source
# File lib/bundler/vendor/compact_index_client/lib/compact_index_client.rb, line 76
def url(path)
  path
end