Class: Guardrails::A11yAudit

Inherits:
Object
  • Object
show all
Defined in:
lib/guardrails/a11y_audit.rb

Overview

Static a11y checks that don’t require a browser — element-level rules that can be answered from the source. For runtime a11y (color contrast, focus order, ARIA tree, dynamic content) integrate axe-core-rspec alongside Guardrails; see doc/A11Y.md.

Defined Under Namespace

Classes: Finding

Constant Summary collapse

SCAN_PATTERNS =
[
  "app/views/**/*.html.erb",
  "app/components/**/*.html.erb"
].freeze
NON_INTERACTIVE_INPUT_TYPES =
%w[hidden submit button reset image].freeze

Instance Method Summary collapse

Constructor Details

#initialize(root:, output: $stdout) ⇒ A11yAudit

Returns a new instance of A11yAudit.



26
27
28
29
# File 'lib/guardrails/a11y_audit.rb', line 26

def initialize(root:, output: $stdout)
  @root = Pathname(root)
  @output = output
end

Instance Method Details

#runObject



31
32
33
34
35
# File 'lib/guardrails/a11y_audit.rb', line 31

def run
  findings = view_files.flat_map { |path| scan_file(path) }
  print_report(findings)
  findings
end