summaryrefslogtreecommitdiff
path: root/lib/rubygems/config_file.rb
diff options
context:
space:
mode:
authorHiroshi SHIBATA <hsbt@ruby-lang.org>2023-04-17 13:44:17 +0900
committergit <svn-admin@ruby-lang.org>2023-04-19 06:56:13 +0000
commit6f50ecfe664924c086879273a29a2ecea9e51683 (patch)
tree3b3e2c0f0a753f6500e80c11ef4b5f46744129c7 /lib/rubygems/config_file.rb
parent628e432739e1d2578d357420aa652a97eb8c2649 (diff)
[rubygems/rubygems] Try to use pure-ruby YAML serializer for configuration
https://github.com/rubygems/rubygems/commit/3268d40974
Diffstat (limited to 'lib/rubygems/config_file.rb')
-rw-r--r--lib/rubygems/config_file.rb11
1 files changed, 5 insertions, 6 deletions
diff --git a/lib/rubygems/config_file.rb b/lib/rubygems/config_file.rb
index 9d38d8b134..3160f6c4aa 100644
--- a/lib/rubygems/config_file.rb
+++ b/lib/rubygems/config_file.rb
@@ -324,11 +324,11 @@ if you believe they were disclosed to a third party.
require "fileutils"
FileUtils.mkdir_p(dirname)
- Gem.load_yaml
+ require "bundler/yaml_serializer"
permissions = 0o600 & (~File.umask)
File.open(credentials_path, "w", permissions) do |f|
- f.write config.to_yaml
+ f.write Bundler::YAMLSerializer.dump(config)
end
load_api_keys # reload
@@ -344,15 +344,14 @@ if you believe they were disclosed to a third party.
end
def load_file(filename)
- Gem.load_yaml
+ require "bundler/yaml_serializer"
yaml_errors = [ArgumentError]
- yaml_errors << Psych::SyntaxError if defined?(Psych::SyntaxError)
return {} unless filename && !filename.empty? && File.exist?(filename)
begin
- content = Gem::SafeYAML.load(File.read(filename))
+ content = Bundler::YAMLSerializer.load(File.read(filename))
unless content.is_a? Hash
warn "Failed to load #{filename} because it doesn't contain valid YAML hash"
return {}
@@ -487,7 +486,7 @@ if you believe they were disclosed to a third party.
yaml_hash[key.to_s] = value
end
- yaml_hash.to_yaml
+ Bundler::YAMLSerializer.dump(yaml_hash)
end
# Writes out this config file, replacing its source.