Class: Rubygems::Await::DependencyAPIAwaiter

Inherits:
Awaiter
  • Object
show all
Defined in:
lib/rubygems/await.rb

Instance Attribute Summary

Attributes inherited from Awaiter

#deadline, #gems, #name_indent, #source, #source_uri

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Awaiter

#call, call, #compact_index_client, #downloader, #expired?, #format_element, #gem_remote_fetcher, #index_fetcher, #inherited, #initialize, #log, #log_error, #log_found, #process_element, #safe_load_marshal, subclasses

Constructor Details

This class inherits a constructor from Rubygems::Await::Awaiter

Class Method Details

.awaiter_nameObject



400
401
402
# File 'lib/rubygems/await.rb', line 400

def self.awaiter_name
  "dependency api"
end

Instance Method Details

#collectionObject



379
380
381
# File 'lib/rubygems/await.rb', line 379

def collection
  gems.group_by(&:name).transform_values! { Set.new(_1) }
end

#process_collection(missing) ⇒ Object



383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
# File 'lib/rubygems/await.rb', line 383

def process_collection(missing)
  dependency_api_uri = "#{source_uri}api/v1/dependencies"
  dependency_api_uri.query = URI.encode_www_form(gems: missing.keys.sort)
  marshalled_deps = downloader.fetch(dependency_api_uri).body
  deps = safe_load_marshal(marshalled_deps)

  deps.each do |s|
    name, number, platform = s.values_at(:name, :number, :platform)
    tuple = Gem::NameTuple.new(name, number, platform)
    log_found(tuple) if missing[name].delete?(tuple)
  end

  missing.delete_if do |_name, tuples|
    tuples.empty?
  end
end