Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
class method
Gem::Specification.load
(::String filename, ?::Module | bool) -> bool
load(file)
lib/rubygems/specification.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.1.0-preview1/lib/rubygems/specification.rb, line 1114
def self.load(file)
return unless file
spec = @load_cache_mutex.synchronize { @load_cache[file] }
return spec if spec
return unless File.file?(file)
code = Gem.open_file(file, "r:UTF-8:-", &:read)
begin
spec = eval code, binding, file
if Gem::Specification === spec
spec.loaded_from = File.expand_path file.to_s
@load_cache_mutex.synchronize do
prev = @load_cache[file]
if prev
spec = prev
else
@load_cache[file] = spec
end
end
return spec
end
warn "[#{file}] isn't a Gem::Specification (#{spec.class} instead)."
rescue SignalException, SystemExit
raise
rescue SyntaxError, StandardError => e
warn "Invalid gemspec in [#{file}]: #{e}"
end
nil
end
Loads Ruby format gemspec from file.