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 | baad9eaf388d3dbd5b70163ac3d86b10de7f59d1 (patch) | |
| tree | 8f1591102f7c8e1a27bd3c30b43567ced67e2519 /lib/rubygems.rb | |
| parent | 1639e5fe7076f717b24580f56a692d9ef1c38d5d (diff) | |
| download | ruby-baad9eaf388d3dbd5b70163ac3d86b10de7f59d1.tar.gz ruby-baad9eaf388d3dbd5b70163ac3d86b10de7f59d1.tar.xz ruby-baad9eaf388d3dbd5b70163ac3d86b10de7f59d1.zip | |
Import RubyGems r1601. [ruby-core:15381].
git-svn-id: http://svn.ruby-lang.org/repos/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 e25e05a3b..9549b9bdc 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) |
