mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[rubygems/rubygems] Refactor Gem.load_path_insert_index
https://github.com/rubygems/rubygems/commit/ae95885dff
This commit is contained in:
parent
a18e81d797
commit
5aa5aad48a
Notes:
git
2020-06-05 07:33:42 +09:00
2 changed files with 4 additions and 14 deletions
|
@ -590,7 +590,7 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
|
||||||
|
|
||||||
index = $LOAD_PATH.index RbConfig::CONFIG['sitelibdir']
|
index = $LOAD_PATH.index RbConfig::CONFIG['sitelibdir']
|
||||||
|
|
||||||
index
|
index || 0
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -607,15 +607,8 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
|
||||||
def self.add_to_load_path(*paths)
|
def self.add_to_load_path(*paths)
|
||||||
@activated_gem_paths = activated_gem_paths + paths.size
|
@activated_gem_paths = activated_gem_paths + paths.size
|
||||||
|
|
||||||
insert_index = load_path_insert_index
|
# gem directories must come after -I and ENV['RUBYLIB']
|
||||||
|
$LOAD_PATH.insert(Gem.load_path_insert_index, *paths)
|
||||||
if insert_index
|
|
||||||
# gem directories must come after -I and ENV['RUBYLIB']
|
|
||||||
$LOAD_PATH.insert(insert_index, *paths)
|
|
||||||
else
|
|
||||||
# we are probably testing in core, -I and RUBYLIB don't apply
|
|
||||||
$LOAD_PATH.unshift(*paths)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@yaml_loaded = false
|
@yaml_loaded = false
|
||||||
|
|
|
@ -44,10 +44,7 @@ module Kernel
|
||||||
resolved_path = begin
|
resolved_path = begin
|
||||||
rp = nil
|
rp = nil
|
||||||
Gem.suffixes.each do |s|
|
Gem.suffixes.each do |s|
|
||||||
load_path_insert_index = Gem.load_path_insert_index
|
$LOAD_PATH[0...Gem.load_path_insert_index - Gem.activated_gem_paths].each do |lp|
|
||||||
break unless load_path_insert_index
|
|
||||||
|
|
||||||
$LOAD_PATH[0...load_path_insert_index - Gem.activated_gem_paths].each do |lp|
|
|
||||||
safe_lp = lp.dup.tap(&Gem::UNTAINT)
|
safe_lp = lp.dup.tap(&Gem::UNTAINT)
|
||||||
begin
|
begin
|
||||||
if File.symlink? safe_lp # for backward compatibility
|
if File.symlink? safe_lp # for backward compatibility
|
||||||
|
|
Loading…
Add table
Reference in a new issue