Module: RuboCop::FileFinder

Included in:
Config, ConfigLoader
Defined in:
lib/rubocop/file_finder.rb

Overview

Common methods for finding files.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.root_level=(level) ⇒ Object



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

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

.root_level?(path) ⇒ Boolean

Returns:

  • (Boolean)


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

def self.root_level?(path)
  @root_level == path.to_s
end

Instance Method Details

#find_file_upwards(filename, start_dir) ⇒ Object



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

def find_file_upwards(filename, start_dir)
  traverse_files_upwards(filename, start_dir) do |file|
    # minimize iteration for performance
    return file if file
  end
end

#find_files_upwards(filename, start_dir) ⇒ Object



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

def find_files_upwards(filename, start_dir)
  files = []
  traverse_files_upwards(filename, start_dir) do |file|
    files << file
  end
  files
end