Class: Fasterer::FileTraverser

Inherits:
Object
  • Object
show all
Defined in:
lib/fasterer/file_traverser.rb

Constant Summary collapse

CONFIG_FILE_NAME =
Config::FILE_NAME
SPEEDUPS_KEY =
Config::SPEEDUPS_KEY
EXCLUDE_PATHS_KEY =
Config::EXCLUDE_PATHS_KEY

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ FileTraverser

Returns a new instance of FileTraverser.



16
17
18
19
20
# File 'lib/fasterer/file_traverser.rb', line 16

def initialize(path)
  @path = Pathname(path)
  @parse_error_paths = []
  @config = Config.new
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



13
14
15
# File 'lib/fasterer/file_traverser.rb', line 13

def config
  @config
end

#parse_error_pathsObject (readonly)

Returns the value of attribute parse_error_paths.



14
15
16
# File 'lib/fasterer/file_traverser.rb', line 14

def parse_error_paths
  @parse_error_paths
end

Instance Method Details

#config_fileObject



31
32
33
# File 'lib/fasterer/file_traverser.rb', line 31

def config_file
  config.file
end

#offenses_found?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/fasterer/file_traverser.rb', line 35

def offenses_found?
  !!offenses_found
end

#traverseObject



22
23
24
25
26
27
28
29
# File 'lib/fasterer/file_traverser.rb', line 22

def traverse
  if @path.directory?
    scannable_files.each { |ruby_file| scan_file(ruby_file) }
  else
    scan_file(@path)
  end
  output_parse_errors if parse_error_paths.any?
end