diff options
author | Carl Lerche <carllerche@mac.com> | 2010-08-06 11:46:26 -0700 |
---|---|---|
committer | Carl Lerche <carllerche@mac.com> | 2010-08-06 11:51:55 -0700 |
commit | 27800e7961165fe7582098fe9f9c52bd10fbbd97 (patch) | |
tree | 2f27f12ce8e5dd37cb3776a88414727487b35653 | |
parent | 998863c729389eb79e8e4ac33982325dd329db89 (diff) | |
download | bundler-27800e7961165fe7582098fe9f9c52bd10fbbd97.tar.gz |
Provide an environment variable to allow customizing the location of <app>/.bundle
-rw-r--r-- | lib/bundler.rb | 8 | ||||
-rw-r--r-- | lib/bundler/environment.rb | 2 | ||||
-rw-r--r-- | lib/bundler/settings.rb | 2 | ||||
-rw-r--r-- | spec/other/config_spec.rb | 40 | ||||
-rw-r--r-- | spec/spec_helper.rb | 3 |
5 files changed, 51 insertions, 4 deletions
diff --git a/lib/bundler.rb b/lib/bundler.rb index da9b2361a9..6829c990e7 100644 --- a/lib/bundler.rb +++ b/lib/bundler.rb @@ -153,6 +153,12 @@ module Bundler default_gemfile.dirname.expand_path end + def app_config_path + ENV['BUNDLE_APP_CONFIG'] ? + Pathname.new(ENV['BUNDLE_APP_CONFIG']).expand_path(root) : + root.join('.bundle') + end + def app_cache root.join("vendor/cache") end @@ -162,7 +168,7 @@ module Bundler end def settings - @settings ||= Settings.new(root) + @settings ||= Settings.new(app_config_path) end def with_clean_env diff --git a/lib/bundler/environment.rb b/lib/bundler/environment.rb index c5a44d1be3..d821951676 100644 --- a/lib/bundler/environment.rb +++ b/lib/bundler/environment.rb @@ -6,7 +6,7 @@ module Bundler @root = root @definition = definition - env_file = root.join('.bundle/environment.rb') + env_file = Bundler.app_config_path.join('environment.rb') env_file.rmtree if env_file.exist? end diff --git a/lib/bundler/settings.rb b/lib/bundler/settings.rb index f6b2972918..b5369e63ea 100644 --- a/lib/bundler/settings.rb +++ b/lib/bundler/settings.rb @@ -107,7 +107,7 @@ module Bundler end def local_config_file - Pathname.new("#{@root}/.bundle/config") + Pathname.new("#{@root}/config") end end end diff --git a/spec/other/config_spec.rb b/spec/other/config_spec.rb new file mode 100644 index 0000000000..6d059e90ff --- /dev/null +++ b/spec/other/config_spec.rb @@ -0,0 +1,40 @@ +require "spec_helper" + +describe ".bundle/config" do + before :each do + gemfile <<-G + source "file://#{gem_repo1}" + gem "rack", "1.0.0" + G + end + + it "can be moved with an environment variable" do + ENV['BUNDLE_APP_CONFIG'] = tmp('foo/bar').to_s + bundle "install vendor" + + bundled_app('.bundle').should_not exist + tmp('foo/bar/config').should exist + should_be_installed "rack 1.0.0" + end + + it "can provide a relative path with the environment variable" do + FileUtils.mkdir_p bundled_app('omg') + Dir.chdir bundled_app('omg') + + ENV['BUNDLE_APP_CONFIG'] = "../foo" + bundle "install vendor" + + bundled_app(".bundle").should_not exist + bundled_app("../foo/config").should exist + should_be_installed "rack 1.0.0" + end + + it "removes environment.rb from BUNDLE_APP_CONFIG's path" do + FileUtils.mkdir_p(tmp('foo/bar')) + ENV['BUNDLE_APP_CONFIG'] = tmp('foo/bar').to_s + bundle "install" + FileUtils.touch tmp('foo/bar/environment.rb') + should_be_installed "rack 1.0.0" + tmp('foo/bar/environment.rb').should_not exist + end +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 666e2b62a4..e74d6f23ee 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -64,6 +64,7 @@ RSpec.configure do |config| ENV['BUNDLE_GEMFILE'] = nil ENV['BUNDLER_TEST'] = nil ENV['BUNDLER_SPEC_PLATFORM'] = nil - ENV['BUNDLER_SPEC_VERSION'] = nil + ENV['BUNDLER_SPEC_VERSION'] = nil + ENV['BUNDLE_APP_CONFIG'] = nil end end |