class Bundler::Source::Rubygems

def installed_specs

def installed_specs
  @installed_specs ||= begin
    idx = Index.new
    have_bundler = false
    Bundler.rubygems.all_specs.reverse_each do |spec|
      next if spec.name == "bundler" && spec.version.to_s != VERSION
      have_bundler = true if spec.name == "bundler"
      spec.source = self
      idx << spec
    end
    # Always have bundler locally
    unless have_bundler
      # We're running bundler directly from the source
      # so, let's create a fake gemspec for it (it's a path)
      # gemspec
      bundler = Gem::Specification.new do |s|
        s.name     = "bundler"
        s.version  = VERSION
        s.platform = Gem::Platform::RUBY
        s.source   = self
        s.authors  = ["bundler team"]
        s.loaded_from = File.expand_path("..", __FILE__)
      end
      idx << bundler
    end
    idx
  end
end