diff options
author | Carlhuda <carlhuda@engineyard.com> | 2010-07-07 14:36:53 -0700 |
---|---|---|
committer | Carlhuda <carlhuda@engineyard.com> | 2010-07-07 14:36:53 -0700 |
commit | 5b2d02fb6a78bf8b07f7b6d3f9407a961e3a7489 (patch) | |
tree | 59ba50bac87ff630cb806ad551076d26aa97d684 | |
parent | d3647992badb85d908e00769865ebdf1a89a8ea6 (diff) | |
download | bundler-5b2d02fb6a78bf8b07f7b6d3f9407a961e3a7489.tar.gz |
Make bundle install [PATH] namespace its gems to specific rubies
-rw-r--r-- | lib/bundler.rb | 6 | ||||
-rw-r--r-- | lib/bundler/settings.rb | 21 | ||||
-rw-r--r-- | spec/install/gems/platform_spec.rb | 13 | ||||
-rw-r--r-- | spec/install/gems/simple_case_spec.rb | 12 | ||||
-rw-r--r-- | spec/support/path.rb | 5 |
5 files changed, 45 insertions, 12 deletions
diff --git a/lib/bundler.rb b/lib/bundler.rb index 6aedec9a1c..ed7b6100b5 100644 --- a/lib/bundler.rb +++ b/lib/bundler.rb @@ -77,10 +77,8 @@ module Bundler end def bundle_path - @bundle_path ||= begin - path = settings[:path] || Gem.dir - Pathname.new(path).expand_path(root) - end + # STDERR.puts settings.path + @bundle_path ||= Pathname.new(settings.path).expand_path(root) end def bin_path diff --git a/lib/bundler/settings.rb b/lib/bundler/settings.rb index dffdfd86c7..836df391ad 100644 --- a/lib/bundler/settings.rb +++ b/lib/bundler/settings.rb @@ -6,12 +6,12 @@ module Bundler end def [](key) - key = "BUNDLE_#{key.to_s.upcase}" + key = key_for(key) @config[key] || ENV[key] end def []=(key, value) - key = "BUNDLE_#{key.to_s.upcase}" + key = key_for(key) unless @config[key] == value @config[key] = value FileUtils.mkdir_p(config_file.dirname) @@ -32,8 +32,25 @@ module Bundler self[:without] ? self[:without].split(":").map { |w| w.to_sym } : [] end + def path + path = ENV[key_for(:path)] + + return path if path + + if path = self[:path] + engine = defined?(RUBY_ENGINE) ? RUBY_ENGINE : "ruby" + "#{path}/#{engine}/#{RUBY_VERSION}" + else + Gem.dir + end + end + private + def key_for(key) + "BUNDLE_#{key.to_s.upcase}" + end + def config_file Pathname.new("#{@root}/.bundle/config") end diff --git a/spec/install/gems/platform_spec.rb b/spec/install/gems/platform_spec.rb index a7262ea6a4..dbc80c91ea 100644 --- a/spec/install/gems/platform_spec.rb +++ b/spec/install/gems/platform_spec.rb @@ -72,6 +72,19 @@ describe "bundle install across platforms" do should_be_installed "nokogiri 1.4.2" should_not_be_installed "weakling" end + + it "fetches gems again after changing the version of Ruby" do + gemfile <<-G + source "file://#{gem_repo1}" + + gem "rack", "1.0.0" + G + + bundle "install ./vendor" + + engine = defined?(RUBY_ENGINE) ? RUBY_ENGINE : "ruby" + bundled_app("vendor/#{engine}/#{RUBY_VERSION}/gems/rack-1.0.0").should exist + end end # TODO: Don't make the tests hardcoded to a platform diff --git a/spec/install/gems/simple_case_spec.rb b/spec/install/gems/simple_case_spec.rb index 282dc609cd..77444f2dad 100644 --- a/spec/install/gems/simple_case_spec.rb +++ b/spec/install/gems/simple_case_spec.rb @@ -250,7 +250,7 @@ describe "bundle install with gem sources" do bundle :install - bundled_app('vendor/gems/rack-1.0.0').should be_directory + vendored_gems('gems/rack-1.0.0').should be_directory should_be_installed "rack 1.0.0" end @@ -269,7 +269,7 @@ describe "bundle install with gem sources" do it "sets BUNDLE_PATH as the first argument to bundle install" do bundle "install ./vendor" - bundled_app('vendor/gems/rack-1.0.0').should be_directory + vendored_gems('gems/rack-1.0.0').should be_directory should_be_installed "rack 1.0.0" end @@ -278,7 +278,7 @@ describe "bundle install with gem sources" do build_gem "rack", "1.1.0", :to_system => true bundle "install ./vendor" - bundled_app('vendor/gems/rack-1.0.0').should be_directory + vendored_gems('gems/rack-1.0.0').should be_directory should_be_installed "rack 1.0.0" end end @@ -341,11 +341,11 @@ describe "bundle install with gem sources" do gem "rack" G - bundle "install vendor/gems --disable-shared-gems" - FileUtils.rm_rf bundled_app('vendor/gems') + bundle "install vendor --disable-shared-gems" + FileUtils.rm_rf bundled_app('vendor') bundle "install" - bundled_app('vendor/gems/gems/rack-1.0.0').should be_directory + vendored_gems('gems/rack-1.0.0').should be_directory should_be_installed "rack 1.0.0" end end diff --git a/spec/support/path.rb b/spec/support/path.rb index 8e95831363..81ab6b23b2 100644 --- a/spec/support/path.rb +++ b/spec/support/path.rb @@ -30,6 +30,11 @@ module Spec root.join(*path) end + def vendored_gems(path) + engine = defined?(RUBY_ENGINE) ? RUBY_ENGINE : "ruby" + bundled_app("vendor/#{engine}/#{RUBY_VERSION}/#{path}") + end + def cached_gem(path) bundled_app("vendor/cache/#{path}.gem") end |