class Gem::Source

def fetch_spec(name_tuple)

def fetch_spec(name_tuple)
  fetcher = Gem::RemoteFetcher.fetcher
  spec_file_name = name_tuple.spec_name
  source_uri = enforce_trailing_slash(uri) + "#{Gem::MARSHAL_SPEC_DIR}#{spec_file_name}"
  cache_dir = cache_dir source_uri
  local_spec = File.join cache_dir, spec_file_name
  if File.exist? local_spec
    spec = Gem.read_binary local_spec
    spec = Marshal.load(spec) rescue nil
    return spec if spec
  end
  source_uri.path << '.rz'
  spec = fetcher.fetch_path source_uri
  spec = Gem::Util.inflate spec
  if update_cache?
    require "fileutils"
    FileUtils.mkdir_p cache_dir
    File.open local_spec, 'wb' do |io|
      io.write spec
    end
  end
  # TODO: Investigate setting Gem::Specification#loaded_from to a URI
  Marshal.load spec
end