access_lint 0.0.9 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +43 -26
- data/lib/access_lint.rb +6 -1
- data/lib/access_lint/audit.rb +22 -5
- data/lib/access_lint/runner.rb +31 -0
- data/lib/access_lint/version.rb +1 -1
- data/spec/access_lint/audit_spec.rb +7 -5
- data/spec/access_lint/runner_spec.rb +13 -0
- data/vendor/access-lint/bin/auditor.js +4 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c24905f58182a273d81c472cb6039096550665b5
|
4
|
+
data.tar.gz: 64e9ae9282bf3b4a81094952d7a089c3204cbe00
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d92d4c4aaa4e064ca6e246d97bf17748f4a78d6530c2f8e71d37e5c464b42d8a9aef3bc0df1c27f58a883a6c5cb15040894c4dd20f7151353f8652ecefb7c417
|
7
|
+
data.tar.gz: 9356133444a1c5ab3eed241a6823f1f411fd72d35b29224ba677cb38135d211632474828f2d2f9fa89e5d05d1415e252f33036eb06831da58529eeeabe4146f2
|
data/README.md
CHANGED
@@ -1,44 +1,61 @@
|
|
1
1
|
# AccessLint
|
2
|
-
Command line runner for Google Accessibility Developer Tools.
|
3
2
|
|
4
|
-
|
3
|
+
Run accessibility audits on web pages from the command line.
|
5
4
|
|
6
|
-
|
5
|
+
## About
|
7
6
|
|
8
|
-
|
7
|
+
AccessLint uses the [Accessibility Developer Tools](https://github.com/GoogleChrome/accessibility-developer-tools) javascript library to make assertions on the DOM via PhantomJS.
|
9
8
|
|
10
|
-
|
9
|
+
## Installation
|
11
10
|
|
12
|
-
|
11
|
+
$ brew install phantomjs
|
13
12
|
|
14
|
-
|
13
|
+
$ gem install access_lint
|
15
14
|
|
16
|
-
$
|
15
|
+
$ access_lint audit <url-or-filename>
|
17
16
|
|
18
|
-
## Usage
|
17
|
+
## Command Line Usage
|
19
18
|
|
20
|
-
|
19
|
+
Running the `audit` command will return an array of stringified JSON objects to stdout:
|
21
20
|
|
22
|
-
|
21
|
+
$ access_lint audit TARGET # TARGET can be a url or a path to a file
|
23
22
|
|
24
|
-
|
25
|
-
> *** Begin accessibility audit results ***
|
26
|
-
An accessibility audit found
|
27
|
-
Warnings:
|
28
|
-
Warning: AX_FOCUS_01 (These elements are focusable but either invisible or obscured by another element) failed on the following element:
|
29
|
-
body > .container > .site-footer > A
|
30
|
-
See https://code.google.com/p/accessibility-developer-tools/wiki/AuditRules#AX_FOCUS_01:_These_elements_are_focusable_but_either_invisible_o for more information.
|
23
|
+
The JSON structure looks like:
|
31
24
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
25
|
+
[
|
26
|
+
{
|
27
|
+
"element_names": ["<p class=\"foo\">relevant element</p>"], # array of string values for applicable DOM nodes
|
28
|
+
"elements": [DOM node], # array of failing nodes as DOM objects.
|
29
|
+
"severity": "WARNING", # string for the severity of the failure.
|
30
|
+
"status": "PASS", # 'PASS', 'FAIL', or 'NA'
|
31
|
+
"title": "Some description" # string description of the failure.
|
32
|
+
}
|
33
|
+
]
|
39
34
|
|
35
|
+
### Example
|
40
36
|
|
41
|
-
|
37
|
+
$ access_lint audit http://ckundo.com
|
38
|
+
|
39
|
+
[{"element_names": ["<span class=\"blogger-gear\"></span>"], "elements": [DOM node], "severity"=>"Warning", "status"=>"FAIL", "title"=>"Meaningful images should not be used in element backgrounds"}, ...]
|
40
|
+
|
41
|
+
## Rules
|
42
|
+
|
43
|
+
For full descriptions of the audit rules, visit the [Accessibility Developer Tools project wiki](https://github.com/GoogleChrome/accessibility-developer-tools/wiki/Audit-Rules)
|
44
|
+
|
45
|
+
* Audio elements should have controls
|
46
|
+
* ARIA state and property values must be valid
|
47
|
+
* Elements with ARIA roles must use a valid, non-abstract ARIA role
|
48
|
+
* Controls and media elements should have labels
|
49
|
+
* These elements are focusable but either invisible or obscured by another element
|
50
|
+
* Images should have an alt attribute
|
51
|
+
* The purpose of each link should be clear from the link text
|
52
|
+
* Text elements should have a reasonable contrast ratio
|
53
|
+
* role=main should only appear on significant elements
|
54
|
+
* Meaningful images should not be used in element backgrounds
|
55
|
+
* aria-labelledby attributes should refer to an element which exists in the DOM
|
56
|
+
* The web page should have a title that describes topic or purpose
|
57
|
+
* Elements with ARIA roles must have all required attributes for that role
|
58
|
+
* Video elements should use <track> elements to provide captions
|
42
59
|
|
43
60
|
## Contributing
|
44
61
|
|
data/lib/access_lint.rb
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
require "access_lint/version"
|
2
2
|
|
3
3
|
module AccessLint
|
4
|
-
autoload :Audit, 'access_lint/
|
4
|
+
autoload :Audit, 'access_lint/runner'
|
5
|
+
autoload :Runner, 'access_lint/audit'
|
6
|
+
|
7
|
+
class Error < StandardError; end
|
8
|
+
class AuditError < Error; end
|
9
|
+
class ParserError < Error; end
|
5
10
|
end
|
data/lib/access_lint/audit.rb
CHANGED
@@ -3,17 +3,34 @@ require 'json'
|
|
3
3
|
|
4
4
|
module AccessLint
|
5
5
|
class Audit
|
6
|
-
|
6
|
+
attr_reader :target
|
7
7
|
|
8
8
|
def initialize(target)
|
9
9
|
@target = target
|
10
10
|
end
|
11
11
|
|
12
12
|
def run
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
perform_audit
|
14
|
+
end
|
15
|
+
|
16
|
+
def runner
|
17
|
+
@runner ||= Runner.new(@target)
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def perform_audit
|
23
|
+
runner.run
|
24
|
+
@output = runner.output
|
25
|
+
parse_output
|
26
|
+
end
|
27
|
+
|
28
|
+
def parse_output
|
29
|
+
raw_results = JSON.parse(@output)
|
30
|
+
raw_results.map { |result| result.delete('elements') }
|
31
|
+
@results = raw_results.group_by { |result| result['status'] }
|
32
|
+
rescue Exception => e
|
33
|
+
raise AccessLint::ParserError.new(e.message)
|
17
34
|
end
|
18
35
|
end
|
19
36
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module AccessLint
|
2
|
+
class Runner
|
3
|
+
RUNNER_PATH = File.expand_path("../../../vendor/access-lint/bin/auditor.js", __FILE__)
|
4
|
+
attr_reader :output
|
5
|
+
|
6
|
+
def initialize(target)
|
7
|
+
@target = target
|
8
|
+
end
|
9
|
+
|
10
|
+
def run
|
11
|
+
@output = `phantomjs #{RUNNER_PATH} #{@target}`
|
12
|
+
return if audit_success?
|
13
|
+
|
14
|
+
if !phantomjs_installed?
|
15
|
+
raise AccessLint::RunnerError.new("Please install PhantomJS. Visit http://phantomjs.org/ for instructions.")
|
16
|
+
else
|
17
|
+
raise AccessLint::RunnerError.new("PhantomJS exited without success: #{@output}")
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def audit_success?
|
24
|
+
$?.success?
|
25
|
+
end
|
26
|
+
|
27
|
+
def phantomjs_installed?
|
28
|
+
$?.exitstatus != 127
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/access_lint/version.rb
CHANGED
@@ -2,14 +2,16 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
module AccessLint
|
4
4
|
describe Audit do
|
5
|
-
let(:target) { double(:target) }
|
6
5
|
|
7
6
|
describe '#run' do
|
8
|
-
|
7
|
+
it 'return a parsed set of results' do
|
8
|
+
target = double
|
9
|
+
output = JSON.generate([{status: 'passing', foo: 'bar'}])
|
9
10
|
|
10
|
-
|
11
|
-
audit.
|
12
|
-
|
11
|
+
audit = Audit.new(target)
|
12
|
+
audit.stub(:runner) { double(:runner, output: output, run: double) }
|
13
|
+
|
14
|
+
expect(audit.run).to eq "passing"=>[{"status"=>"passing", "foo"=>"bar"}]
|
13
15
|
end
|
14
16
|
end
|
15
17
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: access_lint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cameron Cundiff
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-01-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -86,9 +86,11 @@ files:
|
|
86
86
|
- lib/access_lint.rb
|
87
87
|
- lib/access_lint/audit.rb
|
88
88
|
- lib/access_lint/cli.rb
|
89
|
+
- lib/access_lint/runner.rb
|
89
90
|
- lib/access_lint/version.rb
|
90
91
|
- spec/access_lint/audit_spec.rb
|
91
92
|
- spec/access_lint/cli_spec.rb
|
93
|
+
- spec/access_lint/runner_spec.rb
|
92
94
|
- spec/spec_helper.rb
|
93
95
|
- vendor/access-lint/README.md
|
94
96
|
- vendor/access-lint/bin/auditor.js
|
@@ -122,4 +124,5 @@ summary: AccessLint runs Google Accessibility Developer Tools assertions on a pa
|
|
122
124
|
test_files:
|
123
125
|
- spec/access_lint/audit_spec.rb
|
124
126
|
- spec/access_lint/cli_spec.rb
|
127
|
+
- spec/access_lint/runner_spec.rb
|
125
128
|
- spec/spec_helper.rb
|