Class: Abqari::Audit::A11y

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

Overview

Accessibility rule. Catches structural issues that hurt screen-reader / keyboard users:

- <img> elements without alt attribute (error)
- Multiple <h1> elements per page (warn)
- Missing skip-to-content link (warn)
- Missing <main id="main-content"> landmark (warn)
- Multiple <nav>s without aria-label (warn)

Redirect-stub pages (meta-refresh) are skipped — they have no user-facing content, so landmark rules don't apply.

Instance Method Summary collapse

Methods inherited from Rule

#initialize

Constructor Details

This class inherits a constructor from Abqari::Audit::Rule

Instance Method Details

#runObject



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/abqari/audit/a11y.rb', line 16

def run
  html_files.each do |file|
    url  = page_url(file)
    html = File.read(file, encoding: 'UTF-8')
    next if html =~ /<meta\s+http-equiv=["']refresh/i

    check_img_alt(html, url)
    check_single_h1(html, url)
    check_skip_link(html, url)
    check_main_landmark(html, url)
    check_nav_labels(html, url)
  end
end