diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/rubygems/path_support.rb | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/lib/rubygems/path_support.rb b/lib/rubygems/path_support.rb index 310d6a0669..b7900f67eb 100644 --- a/lib/rubygems/path_support.rb +++ b/lib/rubygems/path_support.rb @@ -24,13 +24,7 @@ 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 = default_home_dir(env) # If @home (aka Gem.paths.home) exists, but we can't write to it, # fall back to Gem.user_dir (the directory used for user installs). @@ -55,6 +49,20 @@ class Gem::PathSupport private ## + # The default home directory. + # This function was broken out to accommodate tests in `bundler/spec/commands/doctor_spec.rb`. + + def default_home_dir(env) + home = env["GEM_HOME"] || Gem.default_dir + + 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). def split_gem_path(gpaths, home) |
