diff options
author | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-03-04 00:29:40 +0000 |
---|---|---|
committer | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-03-04 00:29:40 +0000 |
commit | 5a90f9e8f84533e7859232895fc4bbe6b31cc771 (patch) | |
tree | e15086587f691a1f5bd3c7ddbfa38e825828caf6 /lib/rubygems/path_support.rb | |
parent | f1321bd6e7c2d6b6a29a67074bad6f2742263921 (diff) |
* lib/rubygems.rb, lib/rubygems/*, test/rubygems/*: Update rubygems-2.6.1.
Please see entries of 2.6.0 and 2.6.1 on
https://github.com/rubygems/rubygems/blob/master/History.txt
[fix GH-1270] Patch by @segiddins
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53992 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rubygems/path_support.rb')
-rw-r--r-- | lib/rubygems/path_support.rb | 36 |
1 files changed, 13 insertions, 23 deletions
diff --git a/lib/rubygems/path_support.rb b/lib/rubygems/path_support.rb index afb559d472..618bc793c4 100644 --- a/lib/rubygems/path_support.rb +++ b/lib/rubygems/path_support.rb @@ -22,21 +22,16 @@ class Gem::PathSupport # Constructor. Takes a single argument which is to be treated like a # hashtable, or defaults to ENV, the system environment. # - def initialize(env=ENV) - @env = env - - # note 'env' vs 'ENV'... - @home = env["GEM_HOME"] || ENV["GEM_HOME"] || Gem.default_dir + def initialize(env) + @home = env["GEM_HOME"] || Gem.default_dir if File::ALT_SEPARATOR then @home = @home.gsub(File::ALT_SEPARATOR, File::SEPARATOR) end - self.path = env["GEM_PATH"] || ENV["GEM_PATH"] + @path = split_gem_path env["GEM_PATH"], @home - @spec_cache_dir = - env["GEM_SPEC_CACHE"] || ENV["GEM_SPEC_CACHE"] || - Gem.default_spec_cache_dir + @spec_cache_dir = env["GEM_SPEC_CACHE"] || Gem.default_spec_cache_dir @spec_cache_dir = @spec_cache_dir.dup.untaint end @@ -44,24 +39,19 @@ class Gem::PathSupport private ## - # Set the Gem search path (as reported by Gem.path). + # Split the Gem search path (as reported by Gem.path). - def path=(gpaths) + def split_gem_path gpaths, home # FIX: it should be [home, *path], not [*path, home] gem_path = [] - # FIX: I can't tell wtf this is doing. - gpaths ||= (ENV['GEM_PATH'] || "").empty? ? nil : ENV["GEM_PATH"] - if gpaths - if gpaths.kind_of?(Array) - gem_path = gpaths.dup - else - gem_path = gpaths.split(Gem.path_separator) - if gpaths.end_with?(Gem.path_separator) - gem_path += default_path - end + gem_path = gpaths.split(Gem.path_separator) + # Handle the path_separator being set to a regexp, which will cause + # end_with? to error + if gpaths =~ /#{Gem.path_separator}\z/ + gem_path += default_path end if File::ALT_SEPARATOR then @@ -70,12 +60,12 @@ class Gem::PathSupport end end - gem_path << @home + gem_path << home else gem_path = default_path end - @path = gem_path.uniq + gem_path.uniq end # Return the default Gem path |