mortise 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 046a97517a767827bcaa186f1709f343b8b6f2f6
4
+ data.tar.gz: 751af607e289c6f1159a672239dcd78f10ef4274
5
+ SHA512:
6
+ metadata.gz: 4eed2f7ed8c1b4c4b55bdde7754067f2ae9343130da8eccf368485606a77566c04d4d6a10a116053eac0ef0722e6037f646d434d4355ecc10709ee5e9aece211
7
+ data.tar.gz: 19198ef3eb4091dacda80022b6e19d2f2e0dba4971a8889d349199e4e13ab58f765c629c4bfe469f839c4ba62940ac184b76238d2c32c9b8c3f4a39f412bc105
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.0
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in mortise.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Jaime Iniesta
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,80 @@
1
+ # Mortise [![travis build status](https://secure.travis-ci.org/sitevalidator/mortise.png?branch=master)](http://travis-ci.org/sitevalidator/mortise) [![Code Climate](https://codeclimate.com/github/sitevalidator/mortise/badges/gpa.svg)](https://codeclimate.com/github/sitevalidator/mortise) [![Dependency Status](https://gemnasium.com/sitevalidator/mortise.png)](https://gemnasium.com/sitevalidator/mortise)
2
+
3
+ Mortise is a Ruby client for the [Tenon.io](http://tenon.io/documentation/) accessibility checker. It lets you easily check for accessibility issues on web pages.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'mortise'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install mortise
20
+
21
+ ## Usage
22
+
23
+ You'll need an API Key to use Tenon.io, so first [register](http://tenon.io/register.php) and come back when you've got your API Key.
24
+
25
+ To check accessibility on a web page, just pass Mortise the URL to check and the API key, like this:
26
+
27
+ ```ruby
28
+ checker = Mortise.check('http://validationhell.com', 'YOUR-API-KEY')
29
+ ```
30
+
31
+ Then, you can check the JSON response like this:
32
+
33
+ ```ruby
34
+ checker.raw # {
35
+ # "resultSet":[
36
+ # {
37
+ # "bpID":1,
38
+ # "certainty":100,
39
+ # "errorDescription":"All images must have an alt attribute...
40
+ ```
41
+
42
+ Every issue returned will also accessible in a more friendly way like this, where the
43
+ snake_cased Ruby attributes correspond to the camelCased JSON attributes:
44
+
45
+ ```ruby
46
+ issue = checker.issues.first
47
+
48
+ issue.bp_id
49
+ issue.certainty
50
+ issue.error_description
51
+ issue.error_snippet
52
+ issue.error_title
53
+ issue.position
54
+ issue.priority
55
+ issue.result_title
56
+ issue.signature
57
+ issue.standards
58
+ issue.t_id
59
+ issue.xpath
60
+ ```
61
+
62
+ 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).
63
+
64
+ ## Using a Tenon Enterprise instance
65
+
66
+ 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:
67
+
68
+ Mortise.check('http://example.com', 'YOUR-API-KEY', tenon_uri: 'http://yourchecker.com')
69
+
70
+ ## Development
71
+
72
+ After checking out the repo, run `bundle` to install dependencies. Then, run `bundle console` for an interactive prompt that will allow you to experiment.
73
+
74
+ ## Contributing
75
+
76
+ 1. Fork it ( https://github.com/[my-github-username]/mortise/fork )
77
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
78
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
79
+ 4. Push to the branch (`git push origin my-new-feature`)
80
+ 5. Create a new Pull Request
@@ -0,0 +1,7 @@
1
+ require 'bundler'
2
+ require 'rspec/core/rake_task'
3
+
4
+ Bundler::GemHelper.install_tasks
5
+ RSpec::Core::RakeTask.new :spec
6
+
7
+ task :default => :spec
@@ -0,0 +1,9 @@
1
+ require "mortise/version"
2
+ require "mortise/checker"
3
+ require "mortise/issue"
4
+
5
+ module Mortise
6
+ def self.check(url, key, options = {})
7
+ Mortise::Checker.new(url, key, options)
8
+ end
9
+ end
@@ -0,0 +1,42 @@
1
+ require 'httparty'
2
+ require 'json'
3
+
4
+ module Mortise
5
+ class Checker
6
+ attr_reader :url, :tenon_uri, :key
7
+
8
+ def initialize(url, key, options = {})
9
+ options = defaults.merge(options)
10
+
11
+ @url = url
12
+ @key = key
13
+
14
+ @tenon_uri = options[:tenon_uri]
15
+ end
16
+
17
+ def raw
18
+ @raw ||= JSON.parse HTTParty.post(tenon_uri,
19
+ body: { url: url, key: key },
20
+ headers: { 'Content-Type' => 'application/x-www-form-urlencoded',
21
+ 'Cache-Control' => 'no-cache' }).body
22
+ end
23
+
24
+ def issues
25
+ @issues ||= raw['resultSet'].map { |issue| Mortise::Issue.new(issue) }
26
+ end
27
+
28
+ def errors
29
+ @errors ||= issues.select { |issue| issue.certainty >= 80 }
30
+ end
31
+
32
+ def warnings
33
+ @warnings ||= issues.select { |issue| issue.certainty < 80 }
34
+ end
35
+
36
+ private
37
+
38
+ def defaults
39
+ { tenon_uri: 'https://tenon.io/api/' }
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,23 @@
1
+ module Mortise
2
+ class Issue
3
+ attr_reader :bp_id, :certainty, :error_description, :error_snippet,
4
+ :error_title, :position, :priority, :result_title, :signature,
5
+ :standards, :t_id, :xpath
6
+
7
+ def initialize(data)
8
+ @bp_id = data['bpID']
9
+ @certainty = data['certainty']
10
+ @error_description = data['errorDescription']
11
+ @error_snippet = data['errorSnippet']
12
+ @error_title = data['errorTitle']
13
+ @position = data['position']
14
+ @priority = data['priority']
15
+ @result_title = data['resultTitle']
16
+ @signature = data['signature']
17
+ @standards = data['standards']
18
+ @t_id = data['tID']
19
+ @xpath = data['xpath']
20
+ end
21
+
22
+ end
23
+ end
@@ -0,0 +1,3 @@
1
+ module Mortise
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'mortise/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "mortise"
8
+ spec.version = Mortise::VERSION
9
+ spec.authors = ["Jaime Iniesta"]
10
+ spec.email = ["jaimeiniesta@gmail.com"]
11
+
12
+ spec.summary = %q{Ruby client for the Tenon accessibility checker}
13
+ spec.description = %q{Ruby client to test accessibility of web pages using the Tenon.io JSON API}
14
+ spec.homepage = "https://github.com/sitevalidator/mortise"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_runtime_dependency "httparty", "~> 0.13"
23
+
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ spec.add_development_dependency "rspec", "~> 3.2"
26
+ spec.add_development_dependency "webmock", "~> 1.20"
27
+ end
metadata ADDED
@@ -0,0 +1,113 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mortise
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Jaime Iniesta
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-03-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.13'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.13'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.2'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.2'
55
+ - !ruby/object:Gem::Dependency
56
+ name: webmock
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.20'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.20'
69
+ description: Ruby client to test accessibility of web pages using the Tenon.io JSON
70
+ API
71
+ email:
72
+ - jaimeiniesta@gmail.com
73
+ executables: []
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - ".travis.yml"
79
+ - CODE_OF_CONDUCT.md
80
+ - Gemfile
81
+ - LICENSE.txt
82
+ - README.md
83
+ - Rakefile
84
+ - lib/mortise.rb
85
+ - lib/mortise/checker.rb
86
+ - lib/mortise/issue.rb
87
+ - lib/mortise/version.rb
88
+ - mortise.gemspec
89
+ homepage: https://github.com/sitevalidator/mortise
90
+ licenses:
91
+ - MIT
92
+ metadata: {}
93
+ post_install_message:
94
+ rdoc_options: []
95
+ require_paths:
96
+ - lib
97
+ required_ruby_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ required_rubygems_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ requirements: []
108
+ rubyforge_project:
109
+ rubygems_version: 2.4.5
110
+ signing_key:
111
+ specification_version: 4
112
+ summary: Ruby client for the Tenon accessibility checker
113
+ test_files: []