Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

First pass at being able to set the bundle install path.

  • Loading branch information...
commit bc310f716c37c6c592141808aed223d806ad1850 1 parent de65328
Carl Lerche authored
View
2  bundler.gemspec
@@ -6,7 +6,7 @@ Gem::Specification.new do |s|
s.required_rubygems_version = Gem::Requirement.new(">= 1.3.5") if s.respond_to? :required_rubygems_version=
s.authors = ["Carl Lerche", "Yehuda Katz"]
- s.date = %q{2010-01-31}
+ s.date = %q{2010-02-01}
s.default_executable = %q{bundle}
s.email = ["carlhuda@engineyard.com"]
s.executables = ["bundle"]
View
101 lib/bundler.rb
@@ -23,62 +23,77 @@ class GemNotFound < StandardError; end
class VersionConflict < StandardError; end
class GemfileError < StandardError; end
- def self.ui
- @ui ||= UI.new
- end
+ class << self
+ attr_accessor :ui, :bundle_path
+
+ def configure
+ @configured ||= begin
+ self.bundle_path = Pathname.new(ENV['BUNDLE_PATH'] || Gem.dir)
+ point_gem_home(ENV['BUNDLE_PATH'])
+ true
+ end
+ end
- def self.ui=(ui)
- @ui = ui
- end
+ def ui
+ @ui ||= UI.new
+ end
- def self.setup(*groups)
- gemfile = default_gemfile
- load(gemfile).setup(*groups)
- end
+ def setup(*groups)
+ gemfile = default_gemfile
+ load(gemfile).setup(*groups)
+ end
- def self.load(gemfile = default_gemfile)
- root = Pathname.new(gemfile).dirname
- Environment.new root, definition(gemfile)
- end
+ def load(gemfile = default_gemfile)
+ root = Pathname.new(gemfile).dirname
+ Environment.new root, definition(gemfile)
+ end
- def self.definition(gemfile = default_gemfile)
- root = Pathname.new(gemfile).dirname
- lockfile = root.join("vendor/lock.yml")
- if lockfile.exist?
- Definition.from_lock(lockfile)
- else
- Definition.from_gemfile(gemfile)
+ def definition(gemfile = default_gemfile)
+ configure
+ root = Pathname.new(gemfile).dirname
+ lockfile = root.join("vendor/lock.yml")
+ if lockfile.exist?
+ Definition.from_lock(lockfile)
+ else
+ Definition.from_gemfile(gemfile)
+ end
end
- end
- def self.home
- Pathname.new(Gem.dir).join("bundler")
- end
+ def home
+ Pathname.new(bundle_path).join("bundler")
+ end
- def self.install_path
- home.join("gems")
- end
+ def install_path
+ home.join("gems")
+ end
- def self.cache
- home.join("cache")
- end
+ def cache
+ home.join("cache")
+ end
- def self.root
- default_gemfile.dirname
- end
+ def root
+ default_gemfile.dirname
+ end
+
+ private
-private
+ def default_gemfile
+ current = Pathname.new(Dir.pwd)
- def self.default_gemfile
- current = Pathname.new(Dir.pwd)
+ until current.root?
+ filename = current.join("Gemfile")
+ return filename if filename.exist?
+ current = current.parent
+ end
- until current.root?
- filename = current.join("Gemfile")
- return filename if filename.exist?
- current = current.parent
+ raise GemfileNotFound, "The default Gemfile was not found"
end
- raise GemfileNotFound, "The default Gemfile was not found"
+ def point_gem_home(path)
+ return unless path
+ ENV['GEM_HOME'] = File.expand_path(path, root)
+ ENV['GEM_PATH'] = ''
+ Gem.clear_paths
+ end
end
-
end
View
31 spec/install/gems_spec.rb
@@ -163,7 +163,38 @@
should_be_installed "rack 1.0.0"
end
end
+ end
+
+ describe "with BUNDLE_PATH 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 "installs gems to BUNDLE_PATH" do
+ ENV['BUNDLE_PATH'] = bundled_app('vendor').to_s
+ bundle :install
+
+ bundled_app('vendor/gems/rack-1.0.0').should be_directory
+ should_be_installed "rack 1.0.0"
+ end
+
+ it "installs gems to BUNDLE_PATH from .bundleconfig" do
+ pending
+ config "BUNDLE_PATH" => bundled_app("vendor").to_s
+
+ bundle :install
+
+ bundled_app('vendor/gems/rack-1.0.0').should be_directory
+ should_be_installed "rack 1.0.0"
+ end
end
describe "when packed and locked" do
View
7 spec/spec_helper.rb
@@ -39,7 +39,10 @@
config.after :each do
Gem.platforms = nil
Dir.chdir(original_wd)
- ENV['GEM_HOME'] = ENV['GEM_PATH'] = original_gem_home
- ENV['PATH'] = original_path
+ # Reset ENV
+ ENV['GEM_HOME'] = original_gem_home
+ ENV['GEM_PATH'] = original_gem_home
+ ENV['BUNDLE_PATH'] = nil
+ ENV['PATH'] = original_path
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.