Class: Gramrb::FileScanner

Inherits:
Object
  • Object
show all
Defined in:
lib/gramrb/file_scanner.rb

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ FileScanner

Returns a new instance of FileScanner.

Raises:

  • (ArgumentError)


3
4
5
6
7
8
9
10
11
# File 'lib/gramrb/file_scanner.rb', line 3

def initialize(path)
  raise ArgumentError, ".#{File.extname(path)} files are not supported" if File.extname(path) != '.rb'

  @path = path
  @filename = File.basename(path, '.rb')
  @content = ContentExtractor.new(File.read(path)).extract_all
  @spell_checker = SpellChecker.new(Config.new.allowlisted)
  @string_cleaner = StringCleaner.new
end

Instance Method Details

#scanObject



13
# File 'lib/gramrb/file_scanner.rb', line 13

def scan = (filename_errors + content_errors).any? ? { @path => { filename_errors:, content_errors: } } : {}