lib/rubocop/file_finder.rb in rubocop-1.66.1 vs lib/rubocop/file_finder.rb in rubocop-1.67.0
- old
+ new
@@ -21,18 +21,23 @@
last_file = nil
traverse_files_upwards(filename, start_dir, stop_dir) { |file| last_file = file }
last_file
end
+ def traverse_directories_upwards(start_dir, stop_dir = nil)
+ Pathname.new(start_dir).expand_path.ascend do |dir|
+ yield(dir)
+ dir = dir.to_s
+ break if dir == stop_dir || dir == FileFinder.root_level
+ end
+ end
+
private
def traverse_files_upwards(filename, start_dir, stop_dir)
- Pathname.new(start_dir).expand_path.ascend do |dir|
+ traverse_directories_upwards(start_dir, stop_dir) do |dir|
file = dir + filename
yield(file.to_s) if file.exist?
-
- dir = dir.to_s
- break if dir == stop_dir || dir == FileFinder.root_level
end
end
end
end