From 091c24d51b962745bf887a729c81e847b257dc11 Mon Sep 17 00:00:00 2001 From: drbrain Date: Tue, 4 Jun 2013 21:54:58 +0000 Subject: * lib/rubygems: Update to RubyGems 2.0.3 * test/rubygems: Tests for the above. * NEWS: Added RubyGems 2.0.3 note. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41076 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/rubygems.rb | 4 ++-- lib/rubygems/commands/cert_command.rb | 4 ++-- lib/rubygems/commands/list_command.rb | 2 +- lib/rubygems/defaults.rb | 14 ++++++++++++++ lib/rubygems/security/signer.rb | 10 +++++----- lib/rubygems/test_case.rb | 2 +- 6 files changed, 25 insertions(+), 11 deletions(-) (limited to 'lib') diff --git a/lib/rubygems.rb b/lib/rubygems.rb index cbab206d48..3622f7102d 100644 --- a/lib/rubygems.rb +++ b/lib/rubygems.rb @@ -8,7 +8,7 @@ require 'rbconfig' module Gem - VERSION = '2.0.2' + VERSION = '2.0.3' end # Must be first since it unloads the prelude from 1.9.2 @@ -328,7 +328,7 @@ module Gem end ## - # The path to the data directory specified by the gem name. If the + # The path the the data directory specified by the gem name. If the # package is not available as a gem, return nil. def self.datadir(gem_name) diff --git a/lib/rubygems/commands/cert_command.rb b/lib/rubygems/commands/cert_command.rb index 13e5e2c37c..5a9320f9c4 100644 --- a/lib/rubygems/commands/cert_command.rb +++ b/lib/rubygems/commands/cert_command.rb @@ -180,7 +180,7 @@ For further reading on signing gems see `ri Gem::Security`. end def load_default_cert - cert_file = File.join Gem.user_home, 'gem-public_cert.pem' + cert_file = File.join Gem.default_cert_path cert = File.read cert_file options[:issuer_cert] = OpenSSL::X509::Certificate.new cert rescue Errno::ENOENT @@ -196,7 +196,7 @@ For further reading on signing gems see `ri Gem::Security`. end def load_default_key - key_file = File.join Gem.user_home, 'gem-private_key.pem' + key_file = File.join Gem.default_key_path key = File.read key_file options[:key] = OpenSSL::PKey::RSA.new key rescue Errno::ENOENT diff --git a/lib/rubygems/commands/list_command.rb b/lib/rubygems/commands/list_command.rb index 71b8a93fad..d9b7a9535e 100644 --- a/lib/rubygems/commands/list_command.rb +++ b/lib/rubygems/commands/list_command.rb @@ -3,7 +3,7 @@ require 'rubygems/commands/query_command' ## # An alternate to Gem::Commands::QueryCommand that searches for gems starting -# with the supplied argument. +# with the the supplied argument. class Gem::Commands::ListCommand < Gem::Commands::QueryCommand diff --git a/lib/rubygems/defaults.rb b/lib/rubygems/defaults.rb index 6854e9b760..9c5e303c0e 100644 --- a/lib/rubygems/defaults.rb +++ b/lib/rubygems/defaults.rb @@ -110,4 +110,18 @@ module Gem 'ruby' end end + + ## + # The default signing key path + + def self.default_key_path + File.join Gem.user_home, ".gem", "gem-private_key.pem" + end + + ## + # The default signing certificate chain path + + def self.default_cert_path + File.join Gem.user_home, ".gem", "gem-public_cert.pem" + end end diff --git a/lib/rubygems/security/signer.rb b/lib/rubygems/security/signer.rb index 29b03683b7..78455c0732 100644 --- a/lib/rubygems/security/signer.rb +++ b/lib/rubygems/security/signer.rb @@ -34,12 +34,12 @@ class Gem::Security::Signer @key = key unless @key then - default_key = File.join Gem.user_home, 'gem-private_key.pem' + default_key = File.join Gem.default_key_path @key = default_key if File.exist? default_key end unless @cert_chain then - default_cert = File.join Gem.user_home, 'gem-public_cert.pem' + default_cert = File.join Gem.default_cert_path @cert_chain = [default_cert] if File.exist? default_cert end @@ -110,15 +110,15 @@ class Gem::Security::Signer def re_sign_key # :nodoc: old_cert = @cert_chain.last - disk_cert_path = File.join Gem.user_home, 'gem-public_cert.pem' + disk_cert_path = File.join Gem.default_cert_path disk_cert = File.read disk_cert_path rescue nil disk_key = - File.read File.join(Gem.user_home, 'gem-private_key.pem') rescue nil + File.read File.join(Gem.default_key_path) rescue nil if disk_key == @key.to_pem and disk_cert == old_cert.to_pem then expiry = old_cert.not_after.strftime '%Y%m%d%H%M%S' old_cert_file = "gem-public_cert.pem.expired.#{expiry}" - old_cert_path = File.join Gem.user_home, old_cert_file + old_cert_path = File.join Gem.user_home, ".gem", old_cert_file unless File.exist? old_cert_path then Gem::Security.write old_cert, old_cert_path diff --git a/lib/rubygems/test_case.rb b/lib/rubygems/test_case.rb index d81012cbd3..3da3173285 100644 --- a/lib/rubygems/test_case.rb +++ b/lib/rubygems/test_case.rb @@ -1027,7 +1027,7 @@ Also, a list: end ## - # Returns the path to the key named +key_name+ from test/rubygems/ + # Returns the path tot he key named +key_name+ from test/rubygems def self.key_path key_name File.expand_path "../../../test/rubygems/#{key_name}_key.pem", __FILE__ -- cgit v1.2.3