fetch_spec(name_tuple)
public
Fetches a specification for the given name_tuple.
# File lib/rubygems/source.rb, line 129
def fetch_spec(name_tuple)
fetcher = Gem::RemoteFetcher.fetcher
spec_file_name = name_tuple.spec_name
source_uri = 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?
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