Module: RuboCop::FileFinder Private
- Included in:
- Config, ConfigFinder, ConfigLoader, Cop::InternalAffairs::UndefinedConfig
- Defined in:
- lib/rubocop/file_finder.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Common methods for finding files.
Class Attribute Summary collapse
- .root_level ⇒ Object private
Instance Method Summary collapse
- #find_file_upwards(filename, start_dir, stop_dir = nil) ⇒ Object private
- #find_last_file_upwards(filename, start_dir, stop_dir = nil) ⇒ Object private
- #traverse_directories_upwards(start_dir, stop_dir = nil) ⇒ Object private
Class Attribute Details
.root_level ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
10 11 12 |
# File 'lib/rubocop/file_finder.rb', line 10 def root_level @root_level end |
Instance Method Details
#find_file_upwards(filename, start_dir, stop_dir = nil) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
13 14 15 16 17 18 |
# 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) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
20 21 22 23 24 |
# 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) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
26 27 28 29 30 31 32 |
# 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 |