Class: Abqari::Audit::Rule

Inherits:
Object
  • Object
show all
Defined in:
lib/abqari/audit/rule.rb

Overview

Base class for audit rules. Each rule lives in its own file under lib/abqari/audit/<category>.rb, inherits from this, and implements #run. Shared helpers (html_files, page_url, add) live here so individual rules stay focused on their domain logic.

Rules are stateless across runs — instantiated by Audit#run with the current site and findings list, then discarded. Caching that makes sense for the duration of a single audit (e.g. memoised html_files) lives on the instance.

Direct Known Subclasses

A11y, Content, Dependencies, Links, Performance, Privacy, SEO

Instance Method Summary collapse

Constructor Details

#initialize(site, findings) ⇒ Rule

Returns a new instance of Rule.



15
16
17
18
# File 'lib/abqari/audit/rule.rb', line 15

def initialize(site, findings)
  @site = site
  @findings = findings
end

Instance Method Details

#runObject

Subclasses override. The default raises so a half-finished rule surfaces immediately in tests instead of silently no-opping.

Raises:

  • (NotImplementedError)


22
23
24
# File 'lib/abqari/audit/rule.rb', line 22

def run
  raise NotImplementedError, "#{self.class.name} must implement #run"
end