From 644d7df021e17c70932da3173ec309ae1c8063d5 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Tue, 18 Apr 2023 09:51:06 +0900 Subject: [rubygems/rubygems] Introduce self.dump_with_rubygems_yaml https://github.com/rubygems/rubygems/commit/3d3b0d80a1 --- lib/rubygems/config_file.rb | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'lib/rubygems/config_file.rb') diff --git a/lib/rubygems/config_file.rb b/lib/rubygems/config_file.rb index 029760286f..54b8842c6e 100644 --- a/lib/rubygems/config_file.rb +++ b/lib/rubygems/config_file.rb @@ -320,19 +320,13 @@ if you believe they were disclosed to a third party. config = load_file(credentials_path).merge(host => api_key) - config.transform_keys! do |k| - k.is_a?(Symbol) ? ":#{k}" : k - end - dirname = File.dirname credentials_path require "fileutils" FileUtils.mkdir_p(dirname) - require "bundler/yaml_serializer" - permissions = 0o600 & (~File.umask) File.open(credentials_path, "w", permissions) do |f| - f.write Bundler::YAMLSerializer.dump(config) + f.write self.class.dump_with_rubygems_yaml(config) end load_api_keys # reload @@ -492,12 +486,7 @@ if you believe they were disclosed to a third party. yaml_hash[key.to_s] = value end - yaml_hash.transform_keys! do |k| - k.is_a?(Symbol) ? ":#{k}" : k - end - - require "bundler/yaml_serializer" - Bundler::YAMLSerializer.dump(yaml_hash) + self.class.dump_with_rubygems_yaml(yaml_hash) end # Writes out this config file, replacing its source. @@ -532,6 +521,15 @@ if you believe they were disclosed to a third party. attr_reader :hash protected :hash + def self.dump_with_rubygems_yaml(content) + content.transform_keys! do |k| + k.is_a?(Symbol) ? ":#{k}" : k + end + + require "bundler/yaml_serializer" + Bundler::YAMLSerializer.dump(content) + end + def self.convert_rubygems_config_hash(content) content.transform_keys! do |k| if k.match?(/\A:(.*)\Z/) -- cgit v1.2.3