Module: RuboCop::FileFinder Private

Included in:
Config, ConfigLoader
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 Method Summary collapse

Instance Method Summary collapse

Class Method Details

.root_level=(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.


9
10
11
# File 'lib/rubocop/file_finder.rb', line 9

def self.root_level=(level)
  @root_level = level
end

.root_level?(path, stop_dir) ⇒ Boolean

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.

Returns:

  • (Boolean)

13
14
15
# File 'lib/rubocop/file_finder.rb', line 13

def self.root_level?(path, stop_dir)
  (@root_level || stop_dir) == path.to_s
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.


17
18
19
20
21
22
# File 'lib/rubocop/file_finder.rb', line 17

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.


24
25
26
27
28
29
30
# File 'lib/rubocop/file_finder.rb', line 24

def find_last_file_upwards(filename, start_dir, stop_dir = nil)
  last_file = nil
  traverse_files_upwards(filename, start_dir, stop_dir) do |file|
    last_file = file
  end
  last_file
end