Class: Gem::Resolver::BestSet
- Inherits:
 - 
      ComposedSet
      
        
- Object
 - Set
 - ComposedSet
 - Gem::Resolver::BestSet
 
 
- Defined in:
 - lib/rubygems/resolver/best_set.rb
 
Overview
The BestSet chooses the best available method to query a remote index.
It combines IndexSet and APISet
Instance Attribute Summary
Attributes inherited from ComposedSet
Attributes inherited from Set
Instance Method Summary collapse
- 
  
    
      #find_all(req)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
:nodoc:.
 - 
  
    
      #initialize(sources = Gem.sources)  ⇒ BestSet 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
Creates a BestSet for the given
sourcesor Gem::sources if none are specified. - 
  
    
      #pick_sets  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Picks which sets to use for the configured sources.
 - 
  
    
      #prefetch(reqs)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
:nodoc:.
 - 
  
    
      #pretty_print(q)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
:nodoc:.
 - 
  
    
      #replace_failed_api_set(error)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Replaces a failed APISet for the URI in
errorwith an IndexSet. 
Methods inherited from ComposedSet
#errors, #prerelease=, #remote=
Methods inherited from Set
Constructor Details
Instance Method Details
#find_all(req) ⇒ Object
:nodoc:
      28 29 30 31 32 33 34 35 36  | 
    
      # File 'lib/rubygems/resolver/best_set.rb', line 28 def find_all(req) # :nodoc: pick_sets if @remote && @sets.empty? super rescue Gem::RemoteFetcher::FetchError => e replace_failed_api_set e retry end  | 
  
#pick_sets ⇒ Object
Picks which sets to use for the configured sources.
      22 23 24 25 26  | 
    
      # File 'lib/rubygems/resolver/best_set.rb', line 22 def pick_sets # :nodoc: @sources.each_source do |source| @sets << source.dependency_resolver_set end end  | 
  
#prefetch(reqs) ⇒ Object
:nodoc:
      38 39 40 41 42  | 
    
      # File 'lib/rubygems/resolver/best_set.rb', line 38 def prefetch(reqs) # :nodoc: pick_sets if @remote && @sets.empty? super end  | 
  
#pretty_print(q) ⇒ Object
:nodoc:
      44 45 46 47 48 49 50 51 52  | 
    
      # File 'lib/rubygems/resolver/best_set.rb', line 44 def pretty_print(q) # :nodoc: q.group 2, "[BestSet", "]" do q.breakable q.text "sets:" q.breakable q.pp @sets end end  | 
  
#replace_failed_api_set(error) ⇒ Object
Replaces a failed APISet for the URI in error with an IndexSet.
If no matching APISet can be found the original error is raised.
The calling method must retry the exception to repeat the lookup.
      61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76  | 
    
      # File 'lib/rubygems/resolver/best_set.rb', line 61 def replace_failed_api_set(error) # :nodoc: uri = error.original_uri uri = URI uri unless URI === uri uri = uri + "." raise error unless api_set = @sets.find do |set| Gem::Resolver::APISet === set && set.dep_uri == uri end index_set = Gem::Resolver::IndexSet.new api_set.source @sets.map! do |set| next set unless set == api_set index_set end end  |