module MdSpell

This module holds all the MdSpell code (except mdspell shell command).

Constants

VERSION

Current version

Public Class Methods

run(argv) click to toggle source
# File lib/mdspell.rb, line 12
def self.run(argv)
  cli = MdSpell::CLI.new
  cli.run argv
  cli.files.each(&method(:check_file))

  exit_if_had_errors
end

Private Class Methods

check_file(filename) click to toggle source

Private class methods

# File lib/mdspell.rb, line 22
def self.check_file(filename)
  spell_checker = SpellChecker.new(filename)
  filename = spell_checker.filename

  verbose "Spell-checking #{filename}..."

  spell_checker.typos.each do |typo|
    error "#{filename}:#{typo.line.location}: #{typo.word}"
  end
end
error(str) click to toggle source
# File lib/mdspell.rb, line 39
def self.error(str)
  @had_errors = true
  puts Rainbow(str).red
end
exit_if_had_errors() click to toggle source
# File lib/mdspell.rb, line 45
def self.exit_if_had_errors
  if @had_errors
    # If exit will be suppressed (line in tests or using at_exit), we need to clean @had_errors
    @had_errors = false
    exit(1)
  end
end
verbose(str) click to toggle source
# File lib/mdspell.rb, line 34
def self.verbose(str)
  puts str if Configuration[:verbose]
end