class Spellr::Check
Attributes
files[R]
reporter[R]
Public Class Methods
new(files: [], reporter: Spellr.config.reporter)
click to toggle source
# File lib/spellr/check.rb, line 17 def initialize(files: [], reporter: Spellr.config.reporter) @files = files @reporter = reporter end
Public Instance Methods
check()
click to toggle source
# File lib/spellr/check.rb, line 23 def check files.each do |file| check_and_count_file(file) end reporter.finish end
exit_code()
click to toggle source
# File lib/spellr/check.rb, line 13 def exit_code reporter.exit_code end
Private Instance Methods
check_and_count_file(file)
click to toggle source
# File lib/spellr/check.rb, line 33 def check_and_count_file(file) check_file(file) reporter.output.increment(:checked) rescue Spellr::InvalidByteSequence # sometimes files are binary reporter.warn "Skipped unreadable file: #{aqua file.relative_path}" end
check_file(file, start_at = nil, found_word_proc = wordlist_proc_for(file))
click to toggle source
# File lib/spellr/check.rb, line 41 def check_file(file, start_at = nil, found_word_proc = wordlist_proc_for(file)) Spellr::Tokenizer.new(file, start_at: start_at) .each_token(skip_term_proc: found_word_proc) do |token| reporter.call(token) reporter.output.exit_code = 1 end end
wordlist_proc_for(file)
click to toggle source
# File lib/spellr/check.rb, line 49 def wordlist_proc_for(file) wordlists = Spellr.config.wordlists_for(file).sort_by(&:length).reverse ->(term) { wordlists.any? { |w| w.include?(term) } } end