diff options
author | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-05-14 11:23:11 +0000 |
---|---|---|
committer | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-05-14 11:23:11 +0000 |
commit | 6ff931d6040d0207cd9c81890f686781ed538b26 (patch) | |
tree | 223cafe1489318b9d6de1fe8a22b86b9157fa065 /lib/rubygems | |
parent | 19f0852363d26f44307e40d0c447f7527b4c36d8 (diff) |
merge revision(s) 39491: [Backport #8403]
* lib/rubygems/config_file.rb: Lazily load .gem/credentials to only
check permissions when necessary. RubyGems bug #465
* test/rubygems/test_gem_config_file.rb: Test for the above.
* test/rubygems/test_gem_commands_push_command.rb: Remove duplicated
test.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@40731 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rubygems')
-rw-r--r-- | lib/rubygems/config_file.rb | 39 |
1 files changed, 26 insertions, 13 deletions
diff --git a/lib/rubygems/config_file.rb b/lib/rubygems/config_file.rb index 1a805df7c8..244e845e6f 100644 --- a/lib/rubygems/config_file.rb +++ b/lib/rubygems/config_file.rb @@ -127,16 +127,6 @@ class Gem::ConfigFile attr_accessor :update_sources ## - # API key for RubyGems.org - - attr_reader :rubygems_api_key - - ## - # Hash of RubyGems.org and alternate API keys - - attr_reader :api_keys - - ## # True if we want to force specification of gem server when pushing a gem attr_accessor :disable_default_gem_server @@ -221,13 +211,23 @@ class Gem::ConfigFile @ssl_verify_mode = @hash[:ssl_verify_mode] if @hash.key? :ssl_verify_mode @ssl_ca_cert = @hash[:ssl_ca_cert] if @hash.key? :ssl_ca_cert - load_api_keys + @api_keys = nil + @rubygems_api_key = nil Gem.sources = @hash[:sources] if @hash.key? :sources handle_arguments arg_list end ## + # Hash of RubyGems.org and alternate API keys + + def api_keys + load_api_keys unless @api_keys + + @api_keys + end + + ## # Checks the permissions of the credentials file. If they are not 0600 an # error message is displayed and RubyGems aborts. @@ -273,11 +273,24 @@ if you believe they were disclosed to a third party. end if @api_keys.key? :rubygems_api_key then - @rubygems_api_key = @api_keys[:rubygems_api_key] - @api_keys[:rubygems] = @api_keys.delete :rubygems_api_key unless @api_keys.key? :rubygems + @rubygems_api_key = @api_keys[:rubygems_api_key] + @api_keys[:rubygems] = @api_keys.delete :rubygems_api_key unless + @api_keys.key? :rubygems end end + ## + # Returns the RubyGems.org API key + + def rubygems_api_key + load_api_keys unless @rubygems_api_key + + @rubygems_api_key + end + + ## + # Sets the RubyGems.org API key to +api_key+ + def rubygems_api_key= api_key check_credentials_permissions |