Class: Gem::Resolver::BestSet

Inherits:
ComposedSet show all
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

#sets

Attributes inherited from Set

#errors, #prerelease, #remote

Instance Method Summary collapse

Methods inherited from ComposedSet

#errors, #prerelease=, #remote=

Methods inherited from Set

#remote?

Constructor Details

#initialize(sources = Gem.sources) ⇒ BestSet

Creates a BestSet for the given sources or Gem::sources if none are specified. sources must be a Gem::SourceList.



13
14
15
16
17
# File 'lib/rubygems/resolver/best_set.rb', line 13

def initialize(sources = Gem.sources)
  super()

  @sources = sources
end

Instance Method Details

#find_all(req) ⇒ Object

:nodoc:



28
29
30
31
32
# File 'lib/rubygems/resolver/best_set.rb', line 28

def find_all(req) # :nodoc:
  pick_sets if @remote && @sets.empty?

  super
end

#pick_setsObject

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:



34
35
36
37
38
# File 'lib/rubygems/resolver/best_set.rb', line 34

def prefetch(reqs) # :nodoc:
  pick_sets if @remote && @sets.empty?

  super
end

#pretty_print(q) ⇒ Object

:nodoc:



40
41
42
43
44
45
46
47
48
# File 'lib/rubygems/resolver/best_set.rb', line 40

def pretty_print(q) # :nodoc:
  q.group 2, "[BestSet", "]" do
    q.breakable
    q.text "sets:"

    q.breakable
    q.pp @sets
  end
end