diff options
author | Carlhuda <carlhuda@engineyard.com> | 2010-08-09 16:34:46 -0700 |
---|---|---|
committer | Carlhuda <carlhuda@engineyard.com> | 2010-08-09 16:34:46 -0700 |
commit | 6b60c6054b8ee4ca0b6e1bff1331684f547eee18 (patch) | |
tree | 7864d4a5bc0f39774027a1c2b660f72565b2941e | |
parent | 434bd10c4e7cf5f45e35857afa1152beab8598ce (diff) | |
download | bundler-0-9-stable.tar.gz |
Make the app config dir configurable through an environment variable.0-9-stable
-rw-r--r-- | lib/bundler.rb | 6 | ||||
-rw-r--r-- | lib/bundler/cli.rb | 4 | ||||
-rw-r--r-- | lib/bundler/runtime.rb | 2 | ||||
-rw-r--r-- | lib/bundler/settings.rb | 6 | ||||
-rw-r--r-- | lib/bundler/shared_helpers.rb | 10 | ||||
-rw-r--r-- | spec/install/gems/simple_case_spec.rb | 22 | ||||
-rw-r--r-- | spec/spec_helper.rb | 1 |
7 files changed, 42 insertions, 9 deletions
diff --git a/lib/bundler.rb b/lib/bundler.rb index 90cc8ad064..372436ce98 100644 --- a/lib/bundler.rb +++ b/lib/bundler.rb @@ -135,8 +135,12 @@ module Bundler default_gemfile.dirname end + def app_config_path + SharedHelpers.app_config_path + end + def settings - @settings ||= Settings.new(root) + @settings ||= Settings.new(app_config_path) end def env_file diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb index aec23525ed..0fde5776e9 100644 --- a/lib/bundler/cli.rb +++ b/lib/bundler/cli.rb @@ -227,12 +227,12 @@ module Bundler private def locked? - File.exist?("#{Bundler.root}/Gemfile.lock") || File.exist?("#{Bundler.root}/.bundle/environment.rb") + File.exist?("#{Bundler.root}/Gemfile.lock") || File.exist?("#{Bundler.app_config_path}/environment.rb") end def remove_lockfiles FileUtils.rm_f "#{Bundler.root}/Gemfile.lock" - FileUtils.rm_f "#{Bundler.root}/.bundle/environment.rb" + FileUtils.rm_f "#{Bundler.app_config_path}/environment.rb" end def locate_gem(name) diff --git a/lib/bundler/runtime.rb b/lib/bundler/runtime.rb index 259bf53210..bbe7a818da 100644 --- a/lib/bundler/runtime.rb +++ b/lib/bundler/runtime.rb @@ -61,7 +61,7 @@ module Bundler def lock sources.each { |s| s.lock if s.respond_to?(:lock) } - FileUtils.mkdir_p("#{root}/.bundle") + FileUtils.mkdir_p(Bundler.app_config_path.to_s) write_yml_lock write_rb_lock end diff --git a/lib/bundler/settings.rb b/lib/bundler/settings.rb index 4a5d82c3f9..7bd421e1e1 100644 --- a/lib/bundler/settings.rb +++ b/lib/bundler/settings.rb @@ -1,7 +1,7 @@ module Bundler class Settings - def initialize(root) - @root = root + def initialize(app_config_path) + @dir = app_config_path.to_s @config = File.exist?(config_file) ? YAML.load_file(config_file) : {} end @@ -31,7 +31,7 @@ module Bundler private def config_file - Pathname.new("#{@root}/.bundle/config") + Pathname.new("#{@dir}/config") end end end
\ No newline at end of file diff --git a/lib/bundler/shared_helpers.rb b/lib/bundler/shared_helpers.rb index 783f0e5712..6c9a711813 100644 --- a/lib/bundler/shared_helpers.rb +++ b/lib/bundler/shared_helpers.rb @@ -48,7 +48,13 @@ module Bundler end def env_file - default_gemfile.dirname.join(".bundle/environment.rb") + app_config_path.join("environment.rb") + end + + def app_config_path + ENV['BUNDLE_APP_CONFIG'] ? + Pathname.new(ENV['BUNDLE_APP_CONFIG']) : + default_gemfile.dirname.join(".bundle") end private @@ -164,4 +170,4 @@ module Bundler extend self end -end
\ No newline at end of file +end diff --git a/spec/install/gems/simple_case_spec.rb b/spec/install/gems/simple_case_spec.rb index 39a12da69e..e9278f09ab 100644 --- a/spec/install/gems/simple_case_spec.rb +++ b/spec/install/gems/simple_case_spec.rb @@ -250,6 +250,28 @@ describe "bundle install with gem sources" do end end + describe "when BUNDLE_APP_CONFIG is set" do + before :each do + build_lib "rack", "1.0.0", :to_system => true do |s| + s.write "lib/rack.rb", "raise 'FAIL'" + end + + gemfile <<-G + source "file://#{gem_repo1}" + gem "rack" + G + end + + it "writes the config file to that directory" do + ENV['BUNDLE_APP_CONFIG'] = bundled_app('bundler').to_s + + bundle :install + + bundled_app('bundler').should be_directory + bundled_app('bundler/config').should be_file + end + end + describe "when BUNDLE_PATH is set" do before :each do build_lib "rack", "1.0.0", :to_system => true do |s| diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 102505ca3a..43201d039e 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -57,5 +57,6 @@ Spec::Runner.configure do |config| ENV['GEM_PATH'] = original_gem_home ENV['BUNDLE_PATH'] = nil ENV['BUNDLE_GEMFILE'] = nil + ENV['BUNDLE_APP_CONFIG'] = nil end end |