Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Make the app config dir configurable through an environment variable.

  • Loading branch information...
commit 6b60c6054b8ee4ca0b6e1bff1331684f547eee18 1 parent 434bd10
Carlhuda authored
View
6 lib/bundler.rb
@@ -135,8 +135,12 @@ def root
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
View
4 lib/bundler/cli.rb
@@ -227,12 +227,12 @@ def version
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)
View
2  lib/bundler/runtime.rb
@@ -61,7 +61,7 @@ def actual_dependencies
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
View
6 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 @@ def without
private
def config_file
- Pathname.new("#{@root}/.bundle/config")
+ Pathname.new("#{@dir}/config")
end
end
end
View
10 lib/bundler/shared_helpers.rb
@@ -48,7 +48,13 @@ def in_bundle?
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 @@ def gem(*) ; end
extend self
end
-end
+end
View
22 spec/install/gems/simple_case_spec.rb
@@ -250,6 +250,28 @@
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|
View
1  spec/spec_helper.rb
@@ -57,5 +57,6 @@ def check(*args)
ENV['GEM_PATH'] = original_gem_home
ENV['BUNDLE_PATH'] = nil
ENV['BUNDLE_GEMFILE'] = nil
+ ENV['BUNDLE_APP_CONFIG'] = nil
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.