Skip to content
Browse files

Add the ability to set bundle env settings in a .bundleconfig file

  • Loading branch information...
1 parent bc310f7 commit 5ad1279518d89db97d3ae32c682bcadb2b8b9caf Carl Lerche committed Feb 1, 2010
Showing with 26 additions and 3 deletions.
  1. +17 −2 lib/bundler.rb
  2. +0 −1 spec/install/gems_spec.rb
  3. +9 −0 spec/support/helpers.rb
View
19 lib/bundler.rb
@@ -28,8 +28,7 @@ class << self
def configure
@configured ||= begin
- self.bundle_path = Pathname.new(ENV['BUNDLE_PATH'] || Gem.dir)
- point_gem_home(ENV['BUNDLE_PATH'])
+ point_gem_home(env[:bundle_path])
true
end
end
@@ -38,6 +37,10 @@ def ui
@ui ||= UI.new
end
+ def bundle_path
+ @bundle_path ||= Pathname.new(env[:bundle_path] || Gem.dir)
+ end
+
def setup(*groups)
gemfile = default_gemfile
load(gemfile).setup(*groups)
@@ -89,6 +92,18 @@ def default_gemfile
raise GemfileNotFound, "The default Gemfile was not found"
end
+ def env
+ @env ||= begin
+ env = {}
+ file = "#{root}/.bundleconfig"
+ config = File.exist?(file) ? YAML.load_file(file) : {}
+ %w(BUNDLE_PATH).each do |key|
+ env[key.downcase.to_sym] = config[key] || ENV[key]
+ end
+ env
+ end
+ end
+
def point_gem_home(path)
return unless path
ENV['GEM_HOME'] = File.expand_path(path, root)
View
1 spec/install/gems_spec.rb
@@ -187,7 +187,6 @@
end
it "installs gems to BUNDLE_PATH from .bundleconfig" do
- pending
config "BUNDLE_PATH" => bundled_app("vendor").to_s
bundle :install
View
9 spec/support/helpers.rb
@@ -50,6 +50,15 @@ def ruby(opts, ruby = nil)
%x{#{Gem.ruby} -I#{lib} #{opts} -e "#{ruby}"}.strip
end
+ def config(config = nil)
+ path = bundled_app('.bundleconfig')
+ return YAML.load_file(path) unless config
+ File.open(path, 'w') do |f|
+ f.puts config.to_yaml
+ end
+ config
+ end
+
def gemfile(*args)
path = bundled_app("Gemfile")
path = args.shift if Pathname === args.first

0 comments on commit 5ad1279

Please sign in to comment.
Something went wrong with that request. Please try again.