Class: ROM::Lint::Linter

Inherits:
Object
  • Object
show all
Defined in:
lib/rom/lint/linter.rb

Overview

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.

Examples:

require 'rom/lint/spec'

Direct Known Subclasses

EnumerableDataset, Gateway

Constant Summary collapse

Failure =

A failure raised by +complain+

Class.new(StandardError)

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.each_lint {|String, ROM::Lint| ... } ⇒ Object

Iterate over all lint methods

Yields:


28
29
30
31
32
# 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

Instance Method Details

#lint(name) ⇒ Object

Run a lint method

Parameters:

  • name (String)

Raises:


41
42
43
44
45
46
# File 'lib/rom/lint/linter.rb', line 41

def lint(name)
  before_lint
  public_send name
  after_lint
  true # for assertions
end