diff options
author | Stefan Lance <stefan@lances.net> | 2015-07-17 14:34:34 -0500 |
---|---|---|
committer | Stefan Lance <stefan@lances.net> | 2015-07-20 14:17:48 -0500 |
commit | 426c36551823594f381b1fd136e9836a12f82d8e (patch) | |
tree | c6fe7afd074710a520894b7fe11c5dfb2f3c1465 | |
parent | a3fa32a57817074a1b2056c587aa5114371ea01d (diff) | |
download | bundler-426c36551823594f381b1fd136e9836a12f82d8e.tar.gz |
Move installation path logic to Bundler.settings.path
-rw-r--r-- | lib/bundler/settings.rb | 26 | ||||
-rw-r--r-- | lib/bundler/source/rubygems.rb | 15 |
2 files changed, 24 insertions, 17 deletions
diff --git a/lib/bundler/settings.rb b/lib/bundler/settings.rb index f5eede6480..fae6b45c6a 100644 --- a/lib/bundler/settings.rb +++ b/lib/bundler/settings.rb @@ -134,21 +134,41 @@ module Bundler end # @local_config["BUNDLE_PATH"] should be prioritized over ENV["BUNDLE_PATH"] + # Always returns an absolute path to the bundle directory + # TODO: Document and refactor this method def path key = key_for(:path) path = ENV[key] || @global_config[key] + set_path = "" + install_path = "" if path && !@local_config.key?(key) path = "#{path}/#{Bundler.ruby_scope}" if path != Bundler.rubygems.gem_dir - return path + set_path = path end if path = self[:path] path = "#{path}/#{Bundler.ruby_scope}" if path != Bundler.rubygems.gem_dir - path + set_path = path else - File.join(@root, Bundler.ruby_scope) + set_path = File.join(@root, Bundler.ruby_scope) end + + if set_path == File.join(Bundler.settings.root, Bundler.ruby_scope) + # ? + install_path = set_path + elsif set_path == Bundler.rubygems.gem_dir + # system gems path + install_path = set_path + elsif Pathname.new(set_path).absolute? + # all other absolute paths + install_path = set_path + else + # all relative paths (configured by the user) + install_path = File.join(Bundler::root, Bundler.settings.path) + end + + install_path end def allow_sudo? diff --git a/lib/bundler/source/rubygems.rb b/lib/bundler/source/rubygems.rb index 1da1aaf247..5a8525ef0c 100644 --- a/lib/bundler/source/rubygems.rb +++ b/lib/bundler/source/rubygems.rb @@ -126,20 +126,7 @@ module Bundler install_path = Bundler.tmp(spec.full_name) bin_path = install_path.join("bin") else - - set_path = Bundler.settings.path - - # TODO: document exactly what's going on here and in Bundler.settings.path - if set_path == File.join(Bundler.settings.root, Bundler.ruby_scope) # ? - install_path = Bundler.settings.path - elsif set_path == Bundler.rubygems.gem_dir # system gems path - install_path = Bundler.settings.path - elsif Pathname.new(set_path).absolute? # all other absolute paths - install_path = Bundler.settings.path - else # all relative paths - install_path = File.join(Bundler::root, Bundler.settings.path) - end - + install_path = Bundler.settings.path bin_path = Bundler.system_bindir end |