Class: Accessibility::Checker

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/accessibility/checker.rb

Overview

An Accessibility::Checker is initialized by passing it the URL of the web page to check.

It is in charge of making the request to the access-lint-server, which will perform the accessibility audit using the AccessLint gem and return the results as JSON.

It delegates the results parsing to an Accessibility::Audit, which in turn will consult the raw JSON from this checker to generate the collections of audit rules.

Example:

a11y = Accessibility::Checker.new('http://validationhell.com')

You can (and should) specify the URL where your access-lint-server instance is to be found, as the default value is not a production-ready server, which might be under heavy load:

a11y = Accessibility::Checker.new( 'http://validationhell.com',
                                   checker_uri: 'http://mychecker.com' )

For brevity, you can use the convenience shortcut on the top-level module:

a11y = Accessibility.check('http://validationhell.com')

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url, options = {}) ⇒ Checker

Returns a new instance of Checker.


36
37
38
39
40
41
42
43
# File 'lib/accessibility/checker.rb', line 36

def initialize(url, options = {})
  options = defaults.merge(options)

  @url         = url
  @checker_uri = options[:checker_uri]

  @audit       = Accessibility::Audit.new(self)
end

Instance Attribute Details

#checker_uriObject (readonly)

Returns the value of attribute checker_uri


34
35
36
# File 'lib/accessibility/checker.rb', line 34

def checker_uri
  @checker_uri
end

#urlObject (readonly)

Returns the value of attribute url


34
35
36
# File 'lib/accessibility/checker.rb', line 34

def url
  @url
end

Instance Method Details

#rawObject

Returns the parsed JSON from the response of the access-lint-server


46
47
48
# File 'lib/accessibility/checker.rb', line 46

def raw
  @raw ||= JSON.parse HTTParty.get("#{checker_uri}/check?url=#{url}").body
end