module Hoe::Deps

def get_source_index

def get_source_index
  @@index ||= nil
  return @@index if @@index
  dump = unless File.exist? '.source_index' then
           warn "Fetching full index and caching. This can take a while."
           url = GEMURL + "Marshal.#{Gem.marshal_version}.Z"
           dump = Gem::RemoteFetcher.fetcher.fetch_path url
           dump = Gem.inflate dump
           warn "stripping index to latest gems"
           ary = Marshal.load dump
           h = {}
           Hash[ary].values.sort.each { |spec| h[spec.name] = spec }
           ary = h.map { |k,v| [v.full_name, v] }
           dump = Marshal.dump ary
           open '.source_index', 'wb' do |io| io.write dump end
           dump
         else
           open '.source_index', 'rb' do |io| io.read end
         end
  @@index = Marshal.load dump
end