diff options
author | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-02-10 08:00:19 +0000 |
---|---|---|
committer | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-02-10 08:00:19 +0000 |
commit | 5d613c83ccb6992c6b99e5a23512719604bbdae9 (patch) | |
tree | 8f1591102f7c8e1a27bd3c30b43567ced67e2519 /lib/rubygems.rb | |
parent | c12b28936266c205d174458f0bd21766154048f7 (diff) |
Import RubyGems r1601. [ruby-core:15381].
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15423 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rubygems.rb')
-rw-r--r-- | lib/rubygems.rb | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/lib/rubygems.rb b/lib/rubygems.rb index e25e05a3b8..9549b9bdca 100644 --- a/lib/rubygems.rb +++ b/lib/rubygems.rb @@ -290,6 +290,24 @@ module Gem @ruby end + # Return the index to insert activated gem paths into the $LOAD_PATH + # Defaults to the site lib directory unless gem_prelude.rb has loaded + # paths then it inserts the path before those paths so you can override + # the gem_prelude.rb default $LOAD_PATH paths. + def load_path_insert_index + index = $LOAD_PATH.index ConfigMap[:sitelibdir] + + $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 + end + + index + end + # Activate a gem (i.e. add it to the Ruby load path). The gem # must satisfy all the specified version constraints. If # +autorequire+ is true, then automatically require the specified @@ -345,11 +363,13 @@ module Gem end sitelibdir = ConfigMap[:sitelibdir] - sitelibdir_index = $LOAD_PATH.index sitelibdir - if sitelibdir_index then + # gem directories must come after -I and ENV['RUBYLIB'] + insert_index = load_path_insert_index + + if insert_index then # gem directories must come after -I and ENV['RUBYLIB'] - $LOAD_PATH.insert(sitelibdir_index, *require_paths) + $LOAD_PATH.insert(insert_index, *require_paths) else # we are probably testing in core, -I and RUBYLIB don't apply $LOAD_PATH.unshift(*require_paths) |