Port the changes made in the ruby repository back to the official(?) rubygems repo. This is also the official nomination for the 'most retarded upstream' award. Upstream: yes, at one of two Reference: http://redmine.ruby-lang.org/issues/show/3607 diff -Naur site_ruby/1.9.1/rubygems/config_file.rb lib/rubygems/config_file.rb --- site_ruby/1.9.1/rubygems/config_file.rb 2010-08-24 13:01:50.000000000 +0200 +++ lib/rubygems/config_file.rb 2010-06-08 15:14:51.000000000 +0200 @@ -46,29 +46,12 @@ PLATFORM_DEFAULTS = {} system_config_path = - if Gem.respond_to? :system_config_path - Gem::system_config_path - else begin - require 'Win32API' - - CSIDL_COMMON_APPDATA = 0x0023 - path = 0.chr * 260 - if RUBY_VERSION > '1.9' then - SHGetFolderPath = Win32API.new 'shell32', 'SHGetFolderPath', 'PLPLP', - 'L', :stdcall - SHGetFolderPath.call nil, CSIDL_COMMON_APPDATA, nil, 1, path - else - SHGetFolderPath = Win32API.new 'shell32', 'SHGetFolderPath', 'LLLLP', - 'L' - SHGetFolderPath.call 0, CSIDL_COMMON_APPDATA, 0, 1, path - end - - path.strip + require 'etc.so' + Etc.sysconfdir rescue LoadError '/etc' end - end SYSTEM_WIDE_CONFIG_FILE = File.join system_config_path, 'gemrc' diff -Naur site_ruby/1.9.1/rubygems/custom_require.rb lib/rubygems/custom_require.rb --- site_ruby/1.9.1/rubygems/custom_require.rb 2010-08-24 13:01:50.000000000 +0200 +++ lib/rubygems/custom_require.rb 2010-07-29 17:14:57.000000000 +0200 @@ -4,8 +4,6 @@ # See LICENSE.txt for permissions. #++ -require 'rubygems' - module Kernel ## @@ -30,17 +28,17 @@ def require(path) # :doc: gem_original_require path rescue LoadError => load_error - if load_error.message =~ /#{Regexp.escape path}\z/ and - spec = Gem.searcher.find(path) then - Gem.activate(spec.name, "= #{spec.version}") - gem_original_require path - else - raise load_error + if load_error.message.end_with?(path) + if Gem.try_activate(path) + return gem_original_require(path) + end end + + raise load_error end private :require private :gem_original_require -end +end unless Kernel.private_method_defined?(:gem_original_require) diff -Naur site_ruby/1.9.1/rubygems/install_update_options.rb lib/rubygems/install_update_options.rb --- site_ruby/1.9.1/rubygems/install_update_options.rb 2010-08-24 13:01:50.000000000 +0200 +++ lib/rubygems/install_update_options.rb 2010-06-11 16:02:18.000000000 +0200 @@ -59,8 +59,7 @@ end add_option(:"Install/Update", '-t', '--[no-]test', - 'Run unit tests prior to installation') do |value, options| - options[:test] = value + 'Ignored; just for compatiblity') do |value, options| end add_option(:"Install/Update", '-w', '--[no-]wrappers', @@ -110,7 +109,7 @@ # Default options for the gem install command. def install_update_defaults_str - '--rdoc --no-force --no-test --wrappers' + '--rdoc --no-force --wrappers' end end diff -Naur site_ruby/1.9.1/rubygems/require_paths_builder.rb lib/rubygems/require_paths_builder.rb --- site_ruby/1.9.1/rubygems/require_paths_builder.rb 2010-08-24 13:01:50.000000000 +0200 +++ lib/rubygems/require_paths_builder.rb 2010-06-27 03:41:40.000000000 +0200 @@ -2,15 +2,11 @@ module Gem::RequirePathsBuilder def write_require_paths_file_if_needed(spec = @spec, gem_home = @gem_home) - return if spec.require_paths == ["lib"] && - (spec.bindir.nil? || spec.bindir == "bin") - file_name = File.join(gem_home, 'gems', "#{@spec.full_name}", ".require_paths") - file_name.untaint - File.open(file_name, "w") do |file| - spec.require_paths.each do |path| - file.puts path - end - file.puts spec.bindir if spec.bindir + require_paths = spec.require_paths + return if require_paths.size == 1 and require_paths.first == "lib" + file_name = "#{gem_home}/gems/#{@spec.full_name}/.require_paths".untaint + File.open(file_name, "wb") do |file| + file.puts require_paths end end end diff -Naur site_ruby/1.9.1/rubygems/test_utilities.rb lib/rubygems/test_utilities.rb --- site_ruby/1.9.1/rubygems/test_utilities.rb 2010-08-24 13:01:50.000000000 +0200 +++ lib/rubygems/test_utilities.rb 2010-02-22 03:52:35.000000000 +0100 @@ -131,30 +131,17 @@ #-- # This class was added to flush out problems in Rubinius' IO implementation. -class TempIO - - @@count = 0 - +class TempIO < Tempfile def initialize(string = '') - @tempfile = Tempfile.new "TempIO-#{@@count += 1}" - @tempfile.binmode - @tempfile.write string - @tempfile.rewind - end - - def method_missing(meth, *args, &block) - @tempfile.send(meth, *args, &block) - end - - def respond_to?(meth) - @tempfile.respond_to? meth + super "TempIO" + binmode + write string + rewind end def string - @tempfile.flush - - Gem.read_binary @tempfile.path + flush + Gem.read_binary path end - end diff -Naur site_ruby/1.9.1/rubygems/validator.rb lib/rubygems/validator.rb --- site_ruby/1.9.1/rubygems/validator.rb 2010-08-24 13:01:50.000000000 +0200 +++ lib/rubygems/validator.rb 2010-04-22 10:24:42.000000000 +0200 @@ -165,6 +165,7 @@ errors end +=begin if RUBY_VERSION < '1.9' then class TestRunner def initialize(suite, ui) @@ -192,6 +193,7 @@ autoload :TestRunner, 'test/unit/ui/testrunnerutilities' end +=end ## # Runs unit tests for a given gem specification @@ -212,6 +214,7 @@ test_files.each do |f| require f end +=begin if RUBY_VERSION < '1.9' then suite = Test::Unit::TestSuite.new("#{gem_spec.name}-#{gem_spec.version}") @@ -226,6 +229,9 @@ result = MiniTest::Unit.new result.run end +=end + result = MiniTest::Unit.new + result.run result ensure --- site_ruby/1.9.1/rubygems.rb 2010-08-24 13:01:50.000000000 +0200 +++ lib/rubygems.rb 2010-07-29 17:14:57.000000000 +0200 @@ -7,6 +7,11 @@ gem_disabled = !defined? Gem +unless gem_disabled + # Nuke the Quickloader stuff + Gem::QuickLoader.remove +end + require 'rubygems/defaults' require 'thread' require 'etc' @@ -487,26 +492,8 @@ ## # Finds the user's home directory. - #-- - # Some comments from the ruby-talk list regarding finding the home - # directory: - # - # I have HOME, USERPROFILE and HOMEDRIVE + HOMEPATH. Ruby seems - # to be depending on HOME in those code samples. I propose that - # it should fallback to USERPROFILE and HOMEDRIVE + HOMEPATH (at - # least on Win32). def self.find_home - unless RUBY_VERSION > '1.9' then - ['HOME', 'USERPROFILE'].each do |homekey| - return ENV[homekey] if ENV[homekey] - end - - if ENV['HOMEDRIVE'] && ENV['HOMEPATH'] then - return "#{ENV['HOMEDRIVE']}#{ENV['HOMEPATH']}" - end - end - File.expand_path "~" rescue if File::ALT_SEPARATOR then @@ -594,17 +581,13 @@ # so you can override the gem_prelude.rb default $LOAD_PATH paths. def self.load_path_insert_index - index = $LOAD_PATH.index ConfigMap[:sitelibdir] + $LOAD_PATH.index { |p| p.instance_variable_defined? :@gem_prelude_index } + end - $LOAD_PATH.each_with_index do |path, i| - if path.instance_variables.include?(:@gem_prelude_index) or - path.instance_variables.include?('@gem_prelude_index') then - index = i - break - end + def self.remove_prelude_paths + Gem::QuickLoader::GemLoadPaths.each do |path| + $LOAD_PATH.delete(path) end - - index end ## @@ -1048,7 +1031,7 @@ module Kernel - undef gem if respond_to? :gem # defined in gem_prelude.rb on 1.9 + remove_method :gem if respond_to?(:gem, true) # defined in gem_prelude.rb on 1.9 ## # Use Kernel#gem to activate a specific version of +gem_name+. @@ -1126,13 +1109,27 @@ require 'rubygems/config_file' +class << Gem + remove_method :try_activate if Gem.respond_to?(:try_activate, true) + + def try_activate(path) + spec = Gem.searcher.find(path) + return false unless spec + + Gem.activate(spec.name, "= #{spec.version}") + return true + end +end + ## # Enables the require hook for RubyGems. # -# Ruby 1.9 allows --disable-gems, so we require it when we didn't detect a Gem -# constant at rubygems.rb load time. +# if --disable-rubygems was used, then the prelude wasn't loaded, so +# we need to load the custom_require now. -require 'rubygems/custom_require' if gem_disabled or RUBY_VERSION < '1.9' +if gem_disabled + require 'rubygems/custom_require' +end Gem.clear_paths