diff options
author | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-10-08 01:32:18 +0000 |
---|---|---|
committer | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-10-08 01:32:18 +0000 |
commit | c00e84327f14845bd484e76b5ee5dfeb1fa9ce3d (patch) | |
tree | 9f558dafa363f4f0118d504a50cd4461e2821cd1 /lib/rubygems/util.rb | |
parent | 6b05153a3a75b74b64553d6a46f501d9ee0f0376 (diff) | |
download | ruby-c00e84327f14845bd484e76b5ee5dfeb1fa9ce3d.tar.gz |
Merge rubygems master.
This is RC version of Rubygems 2.7.0.
https://github.com/rubygems/rubygems/commit/688fb7e83c13c3fe7c2bb03c49a2db4c82852aee
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60133 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rubygems/util.rb')
-rw-r--r-- | lib/rubygems/util.rb | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/lib/rubygems/util.rb b/lib/rubygems/util.rb index ead2babc1f..2de45c900b 100644 --- a/lib/rubygems/util.rb +++ b/lib/rubygems/util.rb @@ -109,26 +109,15 @@ module Gem::Util ## # Enumerates the parents of +directory+. - def self.traverse_parents directory + def self.traverse_parents directory, &block return enum_for __method__, directory unless block_given? here = File.expand_path directory - start = here - - Dir.chdir start - - begin - loop do - yield here - - Dir.chdir '..' - - return if Dir.pwd == here # toplevel - - here = Dir.pwd - end - ensure - Dir.chdir start + loop do + Dir.chdir here, &block + new_here = File.expand_path('..', here) + return if new_here == here # toplevel + here = new_here end end |