Permalink
Browse files

Have bundler/setup not require any extra files.

  • Loading branch information...
Carlhuda
Carlhuda committed Feb 11, 2010
1 parent 28d5130 commit e3942263c4307c0777062862a184d49f407c91d4
Showing with 19 additions and 16 deletions.
  1. +1 −1 lib/bundler/setup.rb
  2. +18 −15 lib/bundler/shared_helpers.rb
View
@@ -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'
@@ -16,25 +16,28 @@ def reverse_rubygems_kernel_mixin
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

0 comments on commit e394226

Please sign in to comment.