From c00e84327f14845bd484e76b5ee5dfeb1fa9ce3d Mon Sep 17 00:00:00 2001 From: hsbt Date: Sun, 8 Oct 2017 01:32:18 +0000 Subject: Merge rubygems master. This is RC version of Rubygems 2.7.0. https://github.com/rubygems/rubygems/commit/688fb7e83c13c3fe7c2bb03c49a2db4c82852aee git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60133 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/rubygems/config_file.rb | 37 +++++++++++++------------------------ 1 file changed, 13 insertions(+), 24 deletions(-) (limited to 'lib/rubygems/config_file.rb') diff --git a/lib/rubygems/config_file.rb b/lib/rubygems/config_file.rb index c95d7dd1f1..b98d30cc69 100644 --- a/lib/rubygems/config_file.rb +++ b/lib/rubygems/config_file.rb @@ -336,6 +336,15 @@ if you believe they were disclosed to a third party. load_api_keys # reload end + ## + # Remove the +~/.gem/credentials+ file to clear all the current sessions. + + def unset_api_key! + return false unless File.exist?(credentials_path) + + File.delete(credentials_path) + end + def load_file(filename) Gem.load_yaml @@ -419,31 +428,11 @@ if you believe they were disclosed to a third party. # to_yaml only overwrites things you can't override on the command line. def to_yaml # :nodoc: yaml_hash = {} - yaml_hash[:backtrace] = if @hash.key?(:backtrace) - @hash[:backtrace] - else - DEFAULT_BACKTRACE - end - - yaml_hash[:bulk_threshold] = if @hash.key?(:bulk_threshold) - @hash[:bulk_threshold] - else - DEFAULT_BULK_THRESHOLD - end - + yaml_hash[:backtrace] = @hash.fetch(:backtrace, DEFAULT_BACKTRACE) + yaml_hash[:bulk_threshold] = @hash.fetch(:bulk_threshold, DEFAULT_BULK_THRESHOLD) yaml_hash[:sources] = Gem.sources.to_a - - yaml_hash[:update_sources] = if @hash.key?(:update_sources) - @hash[:update_sources] - else - DEFAULT_UPDATE_SOURCES - end - - yaml_hash[:verbose] = if @hash.key?(:verbose) - @hash[:verbose] - else - DEFAULT_VERBOSITY - end + yaml_hash[:update_sources] = @hash.fetch(:update_sources, DEFAULT_UPDATE_SOURCES) + yaml_hash[:verbose] = @hash.fetch(:verbose, DEFAULT_VERBOSITY) yaml_hash[:ssl_verify_mode] = @hash[:ssl_verify_mode] if @hash.key? :ssl_verify_mode -- cgit v1.2.3