instance method
Gem::Source#fetch_spec
fetch_spec(name_tuple)
lib/rubygems/source.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.0.0/lib/rubygems/source.rb, line 107
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
Gem.load_safe_marshal
spec = begin
Gem::SafeMarshal.safe_load(spec)
rescue StandardError
nil
end
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
Gem.load_safe_marshal
# TODO: Investigate setting Gem::Specification#loaded_from to a URI
Gem::SafeMarshal.safe_load spec
end
Fetches a specification for the given Gem::NameTuple.
See also
#enforce_trailing_slash
#load_specs
#download
#new_dependency_resolver_set
also in
4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0