Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
instance method
Gem::ConfigFile#load_file
load_file(filename)
lib/rubygems/config_file.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.1.0-preview1/lib/rubygems/config_file.rb, line 546
def load_file(filename)
yaml_errors = [ArgumentError]
return {} unless filename && !filename.empty? && File.exist?(filename)
begin
config = self.class.load_with_rubygems_config_hash(File.read(filename))
has_invalid_keys = config.keys.any? {|k| k.to_s.gsub(%r{https?:\/\/}, "").include?(": ") }
has_invalid_values = config.values.any? {|v| v.is_a?(String) && v.gsub(%r{https?:\/\/}, "").match?(/\A\S+: /) }
if has_invalid_keys || has_invalid_values
warn "Failed to load #{filename} because it doesn't contain valid YAML hash"
return {}
else
return config
end
rescue *yaml_errors => e
warn "Failed to load #{filename}, #{e}"
rescue Errno::EACCES
warn "Failed to load #{filename} due to permissions problem."
end
{}
end
No documentation available
See also
#load_api_keys
#normalize_credential_store
#last_update_check=
#really_verbose
also in
4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0