summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-03-17 15:07:00 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-03-17 15:07:00 +0000
commitcae2f1eb8bb5663210734c201e70b458e1146f39 (patch)
tree84379fb63b54dde7bdf7c554e569fb73c8dfedb3 /lib
parentc071b47a22320b389fabb398f5e8a3bb77bd2799 (diff)
merge revision(s) 39621,39622: [Backport #7991]
* lib/rubygems/commands/setup_command.rb: Install .pem files. * test/rubygems/test_gem_commands_setup_command.rb: Test for the above. * lib/rubygems/spec_fetcher.rb: Test HTTPS upgrade with URI::HTTPS, not URI::HTTP. Fixes bug in automatic HTTPS upgrade. * test/rubygems/test_gem_spec_fetcher.rb: Test for the above. * lib/rubygems.rb: Version 2.0.2 * lib/rubygems/test_utilities.rb: Ensure scheme and uri class match. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@39800 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/rubygems.rb2
-rw-r--r--lib/rubygems/commands/setup_command.rb25
-rw-r--r--lib/rubygems/spec_fetcher.rb8
-rw-r--r--lib/rubygems/test_utilities.rb5
4 files changed, 34 insertions, 6 deletions
diff --git a/lib/rubygems.rb b/lib/rubygems.rb
index 80e6a1ff74..b5f58fefa0 100644
--- a/lib/rubygems.rb
+++ b/lib/rubygems.rb
@@ -8,7 +8,7 @@
require 'rbconfig'
module Gem
- VERSION = '2.0.1'
+ VERSION = '2.0.2'
end
# Must be first since it unloads the prelude from 1.9.2
diff --git a/lib/rubygems/commands/setup_command.rb b/lib/rubygems/commands/setup_command.rb
index 4d7b07c0d8..12e60109aa 100644
--- a/lib/rubygems/commands/setup_command.rb
+++ b/lib/rubygems/commands/setup_command.rb
@@ -77,6 +77,8 @@ class Gem::Commands::SetupCommand < Gem::Command
options[:document].uniq!
end
+
+ @verbose = nil
end
def check_ruby_version
@@ -279,18 +281,27 @@ TEXT
end
end
+ def install_file file, dest_dir
+ dest_file = File.join dest_dir, file
+ dest_dir = File.dirname dest_file
+ mkdir_p dest_dir unless File.directory? dest_dir
+
+ install file, dest_file, :mode => 0644
+ end
+
def install_lib(lib_dir)
say "Installing RubyGems" if @verbose
lib_files = rb_files_in 'lib'
+ pem_files = pem_files_in 'lib'
Dir.chdir 'lib' do
lib_files.each do |lib_file|
- dest_file = File.join lib_dir, lib_file
- dest_dir = File.dirname dest_file
- mkdir_p dest_dir unless File.directory? dest_dir
+ install_file lib_file, lib_dir
+ end
- install lib_file, dest_file, :mode => 0644
+ pem_files.each do |pem_file|
+ install_file pem_file, lib_dir
end
end
end
@@ -381,6 +392,12 @@ TEXT
[lib_dir, bin_dir]
end
+ def pem_files_in dir
+ Dir.chdir dir do
+ Dir[File.join('**', '*pem')]
+ end
+ end
+
def rb_files_in dir
Dir.chdir dir do
Dir[File.join('**', '*rb')]
diff --git a/lib/rubygems/spec_fetcher.rb b/lib/rubygems/spec_fetcher.rb
index 62613f7a51..31205b9a06 100644
--- a/lib/rubygems/spec_fetcher.rb
+++ b/lib/rubygems/spec_fetcher.rb
@@ -241,7 +241,13 @@ class Gem::SpecFetcher
https_uri.scheme = 'https'
https_uri += '/'
- Gem::RemoteFetcher.fetcher.fetch_path https_uri, nil, true
+ https_uri = URI https_uri.to_s # cast to URI::HTTPS
+
+ begin
+ Gem::RemoteFetcher.fetcher.fetch_path https_uri, nil, true
+ rescue Gem::RemoteFetcher::FetchError => e
+ raise unless e.message =~ / Not Allowed 405 /
+ end
say "Upgraded #{uri} to HTTPS"
diff --git a/lib/rubygems/test_utilities.rb b/lib/rubygems/test_utilities.rb
index cf96fca43a..eed42f59a7 100644
--- a/lib/rubygems/test_utilities.rb
+++ b/lib/rubygems/test_utilities.rb
@@ -38,6 +38,11 @@ class Gem::FakeFetcher
end
def find_data(path)
+ if URI === path and "URI::#{path.scheme.upcase}" != path.class.name then
+ raise ArgumentError,
+ "mismatch for scheme #{path.scheme} and class #{path.class}"
+ end
+
path = path.to_s
@paths << path
raise ArgumentError, 'need full URI' unless path =~ %r'^https?://'