Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Commit

Permalink
Make bundle install [PATH] namespace its gems to specific rubies
Browse files Browse the repository at this point in the history
  • Loading branch information
Carlhuda committed Jul 7, 2010
1 parent d364799 commit 5b2d02f
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 12 deletions.
6 changes: 2 additions & 4 deletions lib/bundler.rb
Expand Up @@ -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
Expand Down
21 changes: 19 additions & 2 deletions lib/bundler/settings.rb
Expand Up @@ -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)
Expand All @@ -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
Expand Down
13 changes: 13 additions & 0 deletions spec/install/gems/platform_spec.rb
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions spec/install/gems/simple_case_spec.rb
Expand Up @@ -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

Expand All @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions spec/support/path.rb
Expand Up @@ -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
Expand Down

1 comment on commit 5b2d02f

@celeduc
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.