Class: Fontisan::Audit::Check

Inherits:
Object
  • Object
show all
Defined in:
lib/fontisan/audit/check.rb

Overview

Abstract base for all audit checks. A check is a stateless function that examines a loaded font and returns an Array of Models::ValidationReport::Issue records. An empty array means the font passed the check.

Subclasses MUST override Check.call and Check.code.

Checks are intentionally stateless + side-effect free so they can be composed, run in parallel, and tested in isolation.

Class Method Summary collapse

Class Method Details

.call(font) ⇒ Array<Models::ValidationReport::Issue>

Run the check against font.

Parameters:

Returns:

Raises:

  • (NotImplementedError)


21
22
23
24
# File 'lib/fontisan/audit/check.rb', line 21

def self.call(font)
  raise NotImplementedError,
        "#{name} must override .call(font) -> Array<Issue>"
end

.codeSymbol

Unique short identifier for this check (e.g. :table_checksum). Used as the issue category for programmatic filtering.

Returns:

  • (Symbol)

Raises:

  • (NotImplementedError)


30
31
32
33
# File 'lib/fontisan/audit/check.rb', line 30

def self.code
  raise NotImplementedError,
        "#{name} must override .code -> Symbol"
end

.issue(severity:, message:, location: nil) ⇒ Models::ValidationReport::Issue

Build an issue. Centralizes the category so callers don't repeat it.



37
38
39
40
41
42
43
44
# File 'lib/fontisan/audit/check.rb', line 37

def self.issue(severity:, message:, location: nil)
  Models::ValidationReport::Issue.new(
    severity: severity.to_s,
    category: code.to_s,
    message: message,
    location: location,
  )
end