Class: Bundler::CompactIndexClient

Inherits:
Object
  • Object
show all
Defined in:
lib/bundler/vendor/compact_index_client/lib/compact_index_client.rb,
lib/bundler/vendor/compact_index_client/lib/compact_index_client/cache.rb,
lib/bundler/vendor/compact_index_client/lib/compact_index_client/updater.rb,
lib/bundler/vendor/compact_index_client/lib/compact_index_client/version.rb

Defined Under Namespace

Classes: Cache, Error, Updater

Constant Summary collapse

VERSION =
"0.1.0".freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(directory, fetcher) ⇒ CompactIndexClient

Returns a new instance of CompactIndexClient.



19
20
21
22
23
24
25
26
27
28
# 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 = {}
  @in_parallel = lambda do |inputs, &blk|
    inputs.map(&blk)
  end
end

Instance Attribute Details

#directoryObject (readonly)

Returns the value of attribute directory.



12
13
14
# File 'lib/bundler/vendor/compact_index_client/lib/compact_index_client.rb', line 12

def directory
  @directory
end

#in_parallelLambda

Returns A lambda that takes an array of inputs and a block, and maps the inputs with the block in parallel.

Returns:

  • (Lambda)

    A lambda that takes an array of inputs and a block, and maps the inputs with the block in parallel.



17
18
19
# File 'lib/bundler/vendor/compact_index_client/lib/compact_index_client.rb', line 17

def in_parallel
  @in_parallel
end

Instance Method Details

#dependencies(names) ⇒ Object



41
42
43
44
45
46
# File 'lib/bundler/vendor/compact_index_client/lib/compact_index_client.rb', line 41

def dependencies(names)
  in_parallel.call(names) do |name|
    update_info(name)
    @cache.dependencies(name).map {|d| d.unshift(name) }
  end.flatten(1)
end

#namesObject



30
31
32
33
# File 'lib/bundler/vendor/compact_index_client/lib/compact_index_client.rb', line 30

def names
  update(@cache.names_path, "names")
  @cache.names
end

#spec(name, version, platform = nil) ⇒ Object



48
49
50
51
# File 'lib/bundler/vendor/compact_index_client/lib/compact_index_client.rb', line 48

def spec(name, version, platform = nil)
  update_info(name)
  @cache.specific_dependency(name, version, platform)
end

#update_and_parse_checksums!Object



53
54
55
56
57
58
# File 'lib/bundler/vendor/compact_index_client/lib/compact_index_client.rb', line 53

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

#versionsObject



35
36
37
38
39
# File 'lib/bundler/vendor/compact_index_client/lib/compact_index_client.rb', line 35

def versions
  update(@cache.versions_path, "versions")
  versions, @info_checksums_by_name = @cache.versions
  versions
end