class ROM::Lint::Linter
Base class for building linters that check source code
Linters are used by authors of ROM
adapters to verify that their integration complies with the ROM
api.
Most of the time, authors won't need to construct linters directly because the provided test helpers will automatically run when required in tests and specs.
@example
require 'rom/lint/spec'
@api public
Constants
- Failure
A failure raised by
complain
Public Class Methods
Iterate over all lint methods
@yield [String, ROM::Lint]
@api public
# File lib/rom/lint/linter.rb, line 28 def self.each_lint return to_enum unless block_given? lints.each { |lint| yield lint, self } end
Private Class Methods
Return a list a lint methods
@return [String]
@api private
# File lib/rom/lint/linter.rb, line 55 def self.lints public_instance_methods(true).grep(/^lint_/).map(&:to_s) end
Public Instance Methods
Run a lint method
@param [String] name
@raise [ROM::Lint::Linter::Failure] if linting fails
@api public
# File lib/rom/lint/linter.rb, line 41 def lint(name) before_lint public_send name after_lint true # for assertions end
Private Instance Methods
Hook method executed after each lint method run
@api private
# File lib/rom/lint/linter.rb, line 76 def after_lint; end
Hook method executed before each lint method run
@api private
# File lib/rom/lint/linter.rb, line 71 def before_lint; end
Raise a failure if a lint verification fails
@raise [ROM::Lint::Linter::Failure]
@api private
# File lib/rom/lint/linter.rb, line 64 def complain(*args) raise Failure, *args end