Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →
class method
Gem::Util.traverse_parents
traverse_parents(directory, &block)
lib/rubygems/util.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.3.0/lib/rubygems/util.rb, line 82
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.