class method
Gem::Util.traverse_parents
traverse_parents(directory, &block)
lib/rubygems/util.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.0.0/lib/rubygems/util.rb, line 60
def self.traverse_parents(directory, &block)
return enum_for __method__, directory unless block_given?
here = File.expand_path directory
loop do
begin
Dir.chdir here, &block
rescue StandardError
Errno::EACCES
end
new_here = File.expand_path("..", here)
return if new_here == here # toplevel
here = new_here
end
end
Enumerates the parents of directory.