Mortise travis build status Code Climate Dependency Status

Mortise is a Ruby client for the Tenon.io accessibility checker. It lets you easily check for accessibility issues on web pages.

Installation

Add this line to your application's Gemfile:

gem 'mortise'

And then execute:

$ bundle

Or install it yourself as:

$ gem install mortise

Usage

You'll need an API Key to use Tenon.io, so first register and come back when you've got your API Key.

To check accessibility on a web page, just pass Mortise the URL to check and the API key, like this:

checker = Mortise.check('http://validationhell.com', 'YOUR-API-KEY')

Then, you can check the JSON response like this:

checker.raw # {
            #   "resultSet":[
            #     {
            #       "bpID":1,
            #       "certainty":100,
            #       "errorDescription":"All images must have an alt attribute...

Every issue returned will also accessible in a more friendly way like this, where the snake_cased Ruby attributes correspond to the camelCased JSON attributes:

issue = checker.issues.first

issue.bp_id
issue.certainty
issue.error_description
issue.error_snippet
issue.error_title
issue.position
issue.priority
issue.result_title
issue.signature
issue.standards
issue.t_id
issue.xpath

The issues array contains all issues returned by the checker, but you'll typically be more interested in errors (that contains all issues with certainty >= 80) and warnings (that contains all issues with certainty < 80).

Using a Tenon Enterprise instance

By default, Mortise will query the Tenon.io API at http://tenon.io/api/ but if you're using your own Tenon Enterprise instance you can set its location like this:

Mortise.check('http://example.com', 'YOUR-API-KEY', tenon_uri: 'http://yourchecker.com')

Specifying a different Tenon App ID

By default, Mortise will pass its own identifier on the appID parameter, so that Tenon can keep usage stats for Mortise.

If you want to use a different value, you can override it like this:

Mortise.check('http://example.com', 'YOUR-API-KEY', tenon_app_id: 'your-app-id')

Development

After checking out the repo, run bundle to install dependencies. Then, run bundle console for an interactive prompt that will allow you to experiment.

Contributing

  1. Fork it ( https://github.com/[my-github-username]/mortise/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request