* ext/purelib.rb: translates a fake path to rubygems in $" into

an alternative in $: so that Kernel.#require does not load
  more rubygems.rb.
  Resolves many failures in test/rubygems/*.

* gem_prelude.rb (Gem.load_full_rubygems_library): supports case 
  the rubygems to load is not in $(rubylibprefix).
  (Gem.path_to_full_rubygems_library): new method for the changes in
  purelib.rb and Gem.load_full_rubygems_library.
  (Gem.fake_rubygems_as_loaded): new method.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24117 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
yugui 2009-07-15 09:05:32 +00:00
Родитель dc1327a6f2
Коммит 618cb2cab0
3 изменённых файлов: 49 добавлений и 6 удалений

Просмотреть файл

@ -1,3 +1,16 @@
Wed Jul 15 17:33:52 2009 Yuki Sonoda (Yugui) <yugui@yugui.jp>
* ext/purelib.rb: translates a fake path to rubygems in $" into
an alternative in $: so that Kernel.#require does not load
more rubygems.rb.
Resolves many failures in test/rubygems/*.
* gem_prelude.rb (Gem.load_full_rubygems_library): supports case
the rubygems to load is not in $(rubylibprefix).
(Gem.path_to_full_rubygems_library): new method for the changes in
purelib.rb and Gem.load_full_rubygems_library.
(Gem.fake_rubygems_as_loaded): new method.
Wed Jul 15 16:29:35 2009 NAKAMURA Usaku <usa@ruby-lang.org>
* win32/Makefile.sub (LIBPATHFLAG): path is already quoted in mkmf.rb.

Просмотреть файл

@ -6,5 +6,12 @@ $:.each_with_index {|path, index|
end
}
if nul
$:[nul..-1] = ["."]
removed, $:[nul..-1] = $:[nul..-1], ["."]
if defined?(Gem::QuickLoader)
removed.each do |path|
# replaces a fake rubygems by gem_prelude.rb with an alternative path
index = $".index(File.join(path, 'rubygems.rb'))
$"[index] = Gem::QuickLoader.path_to_full_rubygems_library if index
end
end
end

Просмотреть файл

@ -235,18 +235,42 @@ if defined?(Gem) then
Gem::GEM_PRELUDE_METHODS.each do |method_name|
undef_method method_name
end
undef_method :const_missing
undef_method :method_missing
end
Kernel.module_eval do
undef_method :gem if method_defined? :gem
end
$".delete File.join(Gem::ConfigMap[:rubylibprefix],
Gem::ConfigMap[:ruby_version], 'rubygems.rb')
$".delete path_to_full_rubygems_library
$".each do |path|
if /#{Regexp.escape File::SEPARATOR}rubygems\.rb\z/ =~ path
raise LoadError, "another rubygems is already loaded from #{path}"
end
end
require 'rubygems'
end
def self.fake_rubygems_as_loaded
path = path_to_full_rubygems_library
$" << path unless $".include?(path)
end
def self.path_to_full_rubygems_library
installed_path = File.join(Gem::ConfigMap[:rubylibprefix], Gem::ConfigMap[:ruby_version])
if $:.include?(installed_path)
return File.join(installed_path, 'rubygems.rb')
else # e.g., on test-all
$:.each do |dir|
if File.exist?( path = File.join(dir, 'rubygems.rb') )
return path
end
end
raise LoadError, 'rubygems.rb'
end
end
GemPaths = {}
GemVersions = {}
@ -367,8 +391,7 @@ if defined?(Gem) then
begin
Gem.push_all_highest_version_gems_on_load_path
$" << File.join(Gem::ConfigMap[:rubylibprefix],
Gem::ConfigMap[:ruby_version], "rubygems.rb")
Gem::QuickLoader.fake_rubygems_as_loaded
rescue Exception => e
puts "Error loading gem paths on load path in gem_prelude"
puts e