class Bundler::Finder

without causing any gem activation errors.
best possible configuration of gems that satisifes all requirements
to #search. It also resolves a list of dependencies finding the
Finder behaves like a rubygems source index in that it responds

def find_by_name(name)

def find_by_name(name)
  matches = @index[name] ||= begin
    versions = {}
    @sources.reverse_each do |source|
      versions.merge! source.specs[name] || {}
    end
    versions
  end
  matches.values
end

def initialize(*sources)

*sources:: URI pointing to the gem repository
==== Parameters

fetched from the correct source.
track of the original source so that any resolved gem can be
gems from each one. It then combines the indexes together keeping
Takes an array of gem sources and fetches the full index of
def initialize(*sources)
  @cache   = {}
  @index   = {}
  @sources = sources
end

def search(dependency)

matching the search
[Gem::Specification]:: A collection of gem specifications
==== Returns

dependency:: The gem dependency to search for
==== Parameters

Searches for a gem that matches the dependency
def search(dependency)
  @cache[dependency.hash] ||= begin
    find_by_name(dependency.name).select do |spec|
      dependency =~ spec
    end.sort_by {|s| s.version }
  end
end