Permalink
Browse files

Provide an environment variable to allow customizing the location of …

…<app>/.bundle
  • Loading branch information...
1 parent 998863c commit 27800e7961165fe7582098fe9f9c52bd10fbbd97 Carl Lerche committed Aug 6, 2010
Showing with 51 additions and 4 deletions.
  1. +7 −1 lib/bundler.rb
  2. +1 −1 lib/bundler/environment.rb
  3. +1 −1 lib/bundler/settings.rb
  4. +40 −0 spec/other/config_spec.rb
  5. +2 −1 spec/spec_helper.rb
View
@@ -153,6 +153,12 @@ def root
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 @@ def tmp
end
def settings
- @settings ||= Settings.new(root)
+ @settings ||= Settings.new(app_config_path)
end
def with_clean_env
@@ -6,7 +6,7 @@ def initialize(root, definition)
@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
View
@@ -107,7 +107,7 @@ def global_config_file
end
def local_config_file
- Pathname.new("#{@root}/.bundle/config")
+ Pathname.new("#{@root}/config")
end
end
end
View
@@ -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
View
@@ -64,6 +64,7 @@ def check(*args)
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

0 comments on commit 27800e7

Please sign in to comment.