Module: RuboCop::FileFinder Private
Do not use. This module is for internal use only.
Relationships & Source Files | |
Extension / Inclusion / Inheritance Descendants | |
Extended In:
| |
Included In:
| |
Defined in: | lib/rubocop/file_finder.rb |
Overview
Common methods for finding files.
Class Attribute Summary
- .root_level rw Internal use only
Instance Method Summary
- #find_file_upwards(filename, start_dir, stop_dir = nil) Internal use only
- #find_last_file_upwards(filename, start_dir, stop_dir = nil) Internal use only
- #traverse_directories_upwards(start_dir, stop_dir = nil) Internal use only
- #traverse_files_upwards(filename, start_dir, stop_dir) private Internal use only
Class Attribute Details
.root_level (rw)
[ GitHub ]# File 'lib/rubocop/file_finder.rb', line 10
attr_accessor :root_level
Instance Method Details
#find_file_upwards(filename, start_dir, stop_dir = nil)
[ GitHub ]# File 'lib/rubocop/file_finder.rb', line 13
def find_file_upwards(filename, start_dir, stop_dir = nil) traverse_files_upwards(filename, start_dir, stop_dir) do |file| # minimize iteration for performance return file if file end end
#find_last_file_upwards(filename, start_dir, stop_dir = nil)
[ GitHub ]# File 'lib/rubocop/file_finder.rb', line 20
def find_last_file_upwards(filename, start_dir, stop_dir = nil) last_file = nil traverse_files_upwards(filename, start_dir, stop_dir) { |file| last_file = file } last_file end
#traverse_directories_upwards(start_dir, stop_dir = nil)
[ GitHub ]# File 'lib/rubocop/file_finder.rb', line 26
def traverse_directories_upwards(start_dir, stop_dir = nil) Pathname.new(start_dir). .ascend do |dir| yield(dir) dir = dir.to_s break if dir == stop_dir || dir == FileFinder.root_level end end
#traverse_files_upwards(filename, start_dir, stop_dir) (private)
[ GitHub ]# File 'lib/rubocop/file_finder.rb', line 36
def traverse_files_upwards(filename, start_dir, stop_dir) traverse_directories_upwards(start_dir, stop_dir) do |dir| file = dir + filename yield(file.to_s) if file.exist? end end