Skip to content
Browse files

Make bundle install [PATH] namespace its gems to specific rubies

  • Loading branch information...
1 parent d364799 commit 5b2d02fb6a78bf8b07f7b6d3f9407a961e3a7489 Carlhuda committed Jul 7, 2010
Showing with 45 additions and 12 deletions.
  1. +2 −4 lib/bundler.rb
  2. +19 −2 lib/bundler/settings.rb
  3. +13 −0 spec/install/gems/platform_spec.rb
  4. +6 −6 spec/install/gems/simple_case_spec.rb
  5. +5 −0 spec/support/path.rb
View
6 lib/bundler.rb
@@ -77,10 +77,8 @@ def ui
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
View
21 lib/bundler/settings.rb
@@ -6,12 +6,12 @@ def initialize(root)
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 @@ def without
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
View
13 spec/install/gems/platform_spec.rb
@@ -72,6 +72,19 @@
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
View
12 spec/install/gems/simple_case_spec.rb
@@ -250,7 +250,7 @@
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 @@
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 @@
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 @@
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
View
5 spec/support/path.rb
@@ -30,6 +30,11 @@ def bundled_app2(*path)
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

1 comment on commit 5b2d02f

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