From 5db8f999431b22b31c4feecbabb498047bc3e6d2 Mon Sep 17 00:00:00 2001 From: drbrain Date: Sat, 1 Dec 2012 00:42:36 +0000 Subject: * lib/rubygems.rb: Search for gem deps file up the directory tree. * test/rubygems/test_gem.rb: Test for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38097 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/rubygems.rb | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/rubygems.rb b/lib/rubygems.rb index 89f718da24..914204858c 100644 --- a/lib/rubygems.rb +++ b/lib/rubygems.rb @@ -187,9 +187,28 @@ module Gem path = path.dup.untaint if path == "-" - path = GEM_DEP_FILES.find { |f| File.exists?(f) } + here = Dir.pwd + start = here - return unless path + begin + while true + path = GEM_DEP_FILES.find { |f| File.exists?(f) } + + if path + path = File.join here, path + break + end + + Dir.chdir ".." + + # If we're at a toplevel, stop. + return if Dir.pwd == here + + here = Dir.pwd + end + ensure + Dir.chdir start + end end return unless File.exists? path -- cgit v1.2.3