diff options
author | Carlhuda <carlhuda@engineyard.com> | 2010-02-10 17:06:08 -0800 |
---|---|---|
committer | Carlhuda <carlhuda@engineyard.com> | 2010-02-10 17:06:08 -0800 |
commit | e3942263c4307c0777062862a184d49f407c91d4 (patch) | |
tree | b5da5d041d04da9225c1746172b36b1247bdeb4c | |
parent | 28d5130312b32feff55aac3ad414771027a5a43a (diff) | |
download | bundler-e3942263c4307c0777062862a184d49f407c91d4.tar.gz |
Have bundler/setup not require any extra files.
-rw-r--r-- | lib/bundler/setup.rb | 2 | ||||
-rw-r--r-- | lib/bundler/shared_helpers.rb | 33 |
2 files changed, 19 insertions, 16 deletions
diff --git a/lib/bundler/setup.rb b/lib/bundler/setup.rb index c78c2462a7..9f65dfe565 100644 --- a/lib/bundler/setup.rb +++ b/lib/bundler/setup.rb @@ -1,5 +1,5 @@ # This is not actually required by the actual library -require 'bundler' +require 'bundler/shared_helpers' if Bundler::SharedHelpers.in_bundle? require 'rubygems' diff --git a/lib/bundler/shared_helpers.rb b/lib/bundler/shared_helpers.rb index b40432c374..b8043e9ed1 100644 --- a/lib/bundler/shared_helpers.rb +++ b/lib/bundler/shared_helpers.rb @@ -16,25 +16,28 @@ module Bundler end def default_gemfile - if ENV['BUNDLE_GEMFILE'] - return Pathname.new(ENV['BUNDLE_GEMFILE']) - end + gemfile = find_gemfile + gemfile or raise GemfileNotFound, "The default Gemfile was not found" + Pathname.new(gemfile) + end - current = Pathname.new(Dir.pwd) + def in_bundle? + find_gemfile + end - until current.root? - filename = current.join("Gemfile") - return filename if filename.exist? - current = current.parent - end + private - raise GemfileNotFound, "The default Gemfile was not found" - end + def find_gemfile + return ENV['BUNDLE_GEMFILE'] if ENV['BUNDLE_GEMFILE'] - def in_bundle? - default_gemfile - rescue GemfileNotFound - false + previous = nil + current = File.expand_path(Dir.pwd) + + until !File.directory?(current) || current == previous + filename = File.join(current, 'Gemfile') + return filename if File.file?(filename) + current, previous = File.expand_path("#{current}/.."), current + end end extend self |