summaryrefslogtreecommitdiff
path: root/lib/bundler/settings.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/bundler/settings.rb')
-rw-r--r--lib/bundler/settings.rb39
1 files changed, 35 insertions, 4 deletions
diff --git a/lib/bundler/settings.rb b/lib/bundler/settings.rb
index e103957a6b..4020df090b 100644
--- a/lib/bundler/settings.rb
+++ b/lib/bundler/settings.rb
@@ -2,8 +2,7 @@ module Bundler
class Settings
def initialize(root)
@root = root
- @local_config = File.exist?(local_config_file) ? YAML.load_file(local_config_file) : {}
- @global_config = File.exist?(global_config_file) ? YAML.load_file(global_config_file) : {}
+ load_config_files
end
def [](key)
@@ -73,9 +72,9 @@ module Bundler
# @local_config["BUNDLE_PATH"] should be prioritized over ENV["BUNDLE_PATH"]
def path
+ return install_path if install_path?
path = ENV[key_for(:path)] || @global_config[key_for(:path)]
return path if path && !@local_config.key?(key_for(:path))
-
if path = self[:path]
"#{path}/#{Bundler.ruby_scope}"
else
@@ -83,13 +82,40 @@ module Bundler
end
end
+ def install_path?
+ Bundler.settings.all.each do |set|
+ end
+ if Bundler.settings[:install_path]
+ true
+ else
+ false
+ end
+ end
+
+ # @local_config["BUNDLE_INSTALL_PATH"] should be prioritized over ENV["BUNDLE_INSTALL_PATH"]
+ def install_path
+ load_config_files
+ ipath = ENV[key_for(:install_path)] || @global_config[key_for(:install_path)] #if self.install_path?
+ return ipath if ipath && !@local_config.key?(key_for(:install_path))
+ if Bundler.settings[:install_path] #&& !ipath.nil?
+ ipath || Bundler.settings[:install_path]
+ else
+ Gem.dir
+ end
+ end
+
+ def cli
+ @cli = ::Bundler::CLI.new
+ @cli
+ end
+
def allow_sudo?
!@local_config.key?(key_for(:path))
end
private
def key_for(key)
- key = key.to_s.sub(".", "__").upcase
+ key = key.to_s.sub(".", "__").upcase.sub("-", "_")
"BUNDLE_#{key}"
end
@@ -113,5 +139,10 @@ module Bundler
def local_config_file
Pathname.new("#{@root}/config")
end
+
+ def load_config_files
+ @local_config = File.exist?(local_config_file) ? YAML.load_file(local_config_file) : {}
+ @global_config = File.exist?(global_config_file) ? YAML.load_file(global_config_file) : {}
+ end
end
end