Loads type kind of specs fetching from +@uri+ if the on-disk cache
is out of date.
type is one of the following:
:released => Return the list of all released specs :latest =>
Return the list of only the highest version of each gem :prerelease =>
Return the list of all prerelease only specs
# File lib/rubygems/source.rb, line 179
def load_specs(type)
file = FILES[type]
fetcher = Gem::RemoteFetcher.fetcher
file_name = "#{file}.#{Gem.marshal_version}"
spec_path = api_uri + "#{file_name}.gz"
cache_dir = cache_dir spec_path
local_file = File.join(cache_dir, file_name)
retried = false
FileUtils.mkdir_p cache_dir if update_cache?
spec_dump = fetcher.cache_update_path spec_path, local_file, update_cache?
begin
Gem::NameTuple.from_list Marshal.load(spec_dump)
rescue ArgumentError
if update_cache? && !retried
FileUtils.rm local_file
retried = true
retry
else
raise Gem::Exception.new("Invalid spec cache file in #{local_file}")
end
end
end