diff options
Diffstat (limited to 'lib/rubygems/path_support.rb')
-rw-r--r-- | lib/rubygems/path_support.rb | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/lib/rubygems/path_support.rb b/lib/rubygems/path_support.rb index 8103caf324..13091e29ba 100644 --- a/lib/rubygems/path_support.rb +++ b/lib/rubygems/path_support.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + ## # # Gem::PathSupport facilitates the GEM_HOME and GEM_PATH environment settings @@ -23,23 +24,22 @@ class Gem::PathSupport # hashtable, or defaults to ENV, the system environment. # def initialize(env) - @home = env["GEM_HOME"] || Gem.default_dir - - if File::ALT_SEPARATOR - @home = @home.gsub(File::ALT_SEPARATOR, File::SEPARATOR) - end - - @home = expand(@home) - + @home = normalize_home_dir(env["GEM_HOME"] || Gem.default_dir) @path = split_gem_path env["GEM_PATH"], @home @spec_cache_dir = env["GEM_SPEC_CACHE"] || Gem.default_spec_cache_dir - - @spec_cache_dir = @spec_cache_dir.dup.tap(&Gem::UNTAINT) end private + def normalize_home_dir(home) + if File::ALT_SEPARATOR + home = home.gsub(File::ALT_SEPARATOR, File::SEPARATOR) + end + + expand(home) + end + ## # Split the Gem search path (as reported by Gem.path). @@ -52,7 +52,7 @@ class Gem::PathSupport 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/ + if /#{Gem.path_separator}\z/.match?(gpaths) gem_path += default_path end @@ -72,12 +72,7 @@ class Gem::PathSupport # Return the default Gem path def default_path - gem_path = Gem.default_path + [@home] - - if defined?(APPLE_GEM_HOME) - gem_path << APPLE_GEM_HOME - end - gem_path + Gem.default_path + [@home] end def expand(path) |