achecker 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ YzlmYzU0ZTFjOWYzMGQwNmI3NzA2MDhkZDIwM2JiNjEwYWIzYzMwOQ==
5
+ data.tar.gz: !binary |-
6
+ YzhhOTZhMTFhMzJjMzRiOGRkYWU3N2NhNDZjODc5NDQxOWQ1MDRiYw==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ MmY4N2RhMzZlODU3OWZhMmQyN2EzNTA1NDBjMDQxMjhjODc1OTQ1ODMyMmNk
10
+ OGVjY2Q1N2Y3MGE0YWM4M2U2MWRkYjNkNTc1YjdjMzU1MDY1Y2E2ZWZjMzgy
11
+ N2JlZGUxODYyN2RhNWZhZDc3NDhjZTNjMmJhZTc2ZGExMzJhZGE=
12
+ data.tar.gz: !binary |-
13
+ MjYzYmE3NTc0Njc2ZWE3ZWMxNDEzODYwNzhiNTM5ZWVhN2ZhYjg4ZDA2ZmRh
14
+ YzE4MWFkZWQ1ZDMzMGVlZmEzYzc3NDQ4M2M0Zjk2YTAxZWM5MWViMjU2MWY4
15
+ YzUzZDE0YTI1Yzk4YmJlNjgzNDExMjdkMzU0ZDUzN2I0MDY2NDY=
@@ -0,0 +1,15 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
15
+ .DS_Store
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --warnings
@@ -0,0 +1,25 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.2
4
+ - 1.9.3
5
+ - 2.0.0
6
+ - 2.1.0
7
+ - 2.1.1
8
+ - 2.1.2
9
+ - ruby-head
10
+ - jruby-19mode
11
+ - jruby
12
+ - jruby-head
13
+ matrix:
14
+ allow_failures:
15
+ - rvm: jruby-head
16
+ - rvm: ruby-head
17
+ deploy:
18
+ provider: rubygems
19
+ api_key:
20
+ secure: nNu6E7wClBo6DEkl+0Rd0ouQr29YwwruhqCI0op/N1AdL5Vq2DW3pSKHZYHHE36T3y5sudV9GPddnJ2O+hhNsp3pMacC7hkfs/L1Gi5WkJ2s421McX13TGfilX22iEMj4Ezlskka1ovAUuzewri0W3UAX8gNiN6RgaMTS6zRivU=
21
+ gem: achecker
22
+ on:
23
+ tags: true
24
+ all_branches: true
25
+ repo: rmagrin/achecker
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in achecker.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Rafael Magrin
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,63 @@
1
+ # AChecker [![Build Status](https://travis-ci.org/rmagrin/achecker.svg?branch=master)](https://travis-ci.org/rmagrin/achecker) [![Dependency Status](https://gemnasium.com/rmagrin/achecker.svg)](https://gemnasium.com/rmagrin/achecker) [![Code Climate](https://codeclimate.com/github/rmagrin/achecker.png)](https://codeclimate.com/github/rmagrin/achecker)
2
+
3
+ Ruby wrapper for [AChecker Web Accessibility Checker](http://achecker.ca)
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'achecker'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install achecker
20
+
21
+ ## Usage
22
+
23
+ ```ruby
24
+ require 'achecker'
25
+
26
+ # replace with the web service id provided for registered users of achecker.
27
+ id = "222c0b31450b95b0e010f5f83d9c9683f95ca89a"
28
+ checker = AChecker::Api.new(id)
29
+ result = checker.check("http://example.com")
30
+ ```
31
+
32
+ ## Contributing
33
+
34
+ 1. Fork it ( https://github.com/rmagrin/achecker/fork )
35
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
36
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
37
+ 4. Push to the branch (`git push origin my-new-feature`)
38
+ 5. Create a new Pull Request
39
+
40
+ ## License
41
+
42
+ Copyright (c) 2014 Rafael Magrin
43
+
44
+ MIT License
45
+
46
+ Permission is hereby granted, free of charge, to any person obtaining
47
+ a copy of this software and associated documentation files (the
48
+ "Software"), to deal in the Software without restriction, including
49
+ without limitation the rights to use, copy, modify, merge, publish,
50
+ distribute, sublicense, and/or sell copies of the Software, and to
51
+ permit persons to whom the Software is furnished to do so, subject to
52
+ the following conditions:
53
+
54
+ The above copyright notice and this permission notice shall be
55
+ included in all copies or substantial portions of the Software.
56
+
57
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
58
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
59
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
60
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
61
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
62
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
63
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -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 'achecker/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "achecker"
8
+ spec.version = AChecker::VERSION
9
+ spec.authors = ["Rafael Magrin"]
10
+ spec.email = ["rafael.magrin@gmail.com"]
11
+ spec.summary = "Wrapper for AChecker Web Accessibility Checker"
12
+ spec.description = "Wrapper for AChecker Web Accessibility Checker"
13
+ spec.homepage = "https://github.com/rmagrin/achecker"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "nokogiri", "~> 1.6"
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.6"
24
+ spec.add_development_dependency "webmock", "~> 1.18"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "rspec", "~> 3.0"
27
+ end
@@ -0,0 +1,2 @@
1
+ require "achecker/version"
2
+ require "achecker/api"
@@ -0,0 +1,25 @@
1
+ require 'net/http'
2
+ require 'achecker/url_builder'
3
+ require 'achecker/check_result_builder'
4
+
5
+ module AChecker
6
+
7
+ class Api
8
+
9
+ def initialize(id)
10
+ @url_builder = UrlBuilder.new(id)
11
+ @result_builder = CheckResultBuilder.new
12
+ end
13
+
14
+ def check(target_url)
15
+ url = @url_builder.build(target_url, "rest")
16
+ response = Net::HTTP.get_response(url)
17
+
18
+ raise "Error processing \"#{target_url}\". Response status code #{response.code}" unless response.kind_of?(Net::HTTPSuccess)
19
+
20
+ @result_builder.build(target_url, @url_builder.build(target_url, "html"), response.body)
21
+ end
22
+
23
+ end
24
+
25
+ end
@@ -0,0 +1,19 @@
1
+ module AChecker
2
+
3
+ class CheckResult
4
+
5
+ attr_reader :url, :achecker_url, :num_errors
6
+
7
+ def initialize(url, achecker_url, num_errors)
8
+ @url = url
9
+ @achecker_url = achecker_url
10
+ @num_errors = num_errors
11
+ end
12
+
13
+ def has_errors
14
+ @num_errors > 0
15
+ end
16
+
17
+ end
18
+
19
+ end
@@ -0,0 +1,21 @@
1
+ require 'nokogiri'
2
+
3
+ require 'achecker/check_result'
4
+
5
+ module AChecker
6
+
7
+ class CheckResultBuilder
8
+
9
+ def build(url, achecker_url, xml)
10
+ xml_doc = Nokogiri::XML(xml)
11
+
12
+ CheckResult.new(
13
+ url,
14
+ achecker_url,
15
+ xml_doc.xpath("//summary/NumOfErrors")[0].text.to_i
16
+ )
17
+ end
18
+
19
+ end
20
+
21
+ end
@@ -0,0 +1,21 @@
1
+ require 'cgi'
2
+
3
+ module AChecker
4
+
5
+ class UrlBuilder
6
+
7
+ BASE_URL = "http://achecker.ca/checkacc.php"
8
+
9
+ def initialize(id = nil)
10
+ @id = id
11
+ end
12
+
13
+ def build(target_url, output)
14
+ url = "#{BASE_URL}?uri=#{CGI::escape(target_url)}&output=#{output}"
15
+ url = "#{url}&id=#{@id}" if output == "rest"
16
+ URI(url)
17
+ end
18
+
19
+ end
20
+
21
+ end
@@ -0,0 +1,3 @@
1
+ module AChecker
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,42 @@
1
+ require 'spec_helper'
2
+ require 'cgi'
3
+ require 'webmock'
4
+
5
+ include WebMock::API
6
+
7
+ module AChecker
8
+
9
+ describe Api do
10
+
11
+ describe "#check" do
12
+
13
+ it "should check url" do
14
+ id = "12345678"
15
+ url = CGI::escape("http://example.com/some-resource/")
16
+ xml = <<-eos
17
+ <?xml version="1.0" encoding="ISO-8859-1"?>
18
+ <resultset>
19
+ <summary>
20
+ <NumOfErrors>30</NumOfErrors>
21
+ </summary>
22
+ </resultset>
23
+ eos
24
+
25
+
26
+ stub_request(:get, "achecker.ca/checkacc.php")
27
+ .with(:query => {"uri" => url, "id" => id, "output" => "rest"})
28
+ .to_return(:body => xml)
29
+
30
+ api = Api.new(id)
31
+
32
+ result = api.check(url)
33
+
34
+ expect(result.url).to eq(url)
35
+ expect(result.num_errors).to eq(30)
36
+ end
37
+
38
+ end
39
+
40
+ end
41
+
42
+ end
@@ -0,0 +1,36 @@
1
+ require 'spec_helper'
2
+
3
+ module AChecker
4
+
5
+ describe CheckResultBuilder do
6
+
7
+ let (:builder) { CheckResultBuilder.new }
8
+
9
+ describe "#build" do
10
+
11
+ it "should set numbers of errors" do
12
+
13
+ xml = <<-eos
14
+ <?xml version="1.0" encoding="ISO-8859-1"?>
15
+ <resultset>
16
+ <summary>
17
+ <status>FAIL</status>
18
+ <sessionID>ce2a543670703b6d37dc613deda3e64389ad038d</sessionID>
19
+ <NumOfErrors>35</NumOfErrors>
20
+ <NumOfLikelyProblems>0</NumOfLikelyProblems>
21
+ <NumOfPotentialProblems>0</NumOfPotentialProblems>
22
+ <guidelines><guideline>WCAG 2.0 (Level AA)</guideline></guidelines>
23
+ </summary>
24
+ </resultset>
25
+ eos
26
+
27
+ result = builder.build("url", "achecker_url", xml)
28
+
29
+ expect(result.num_errors).to eq(35)
30
+ end
31
+
32
+ end
33
+
34
+ end
35
+
36
+ end
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ module AChecker
4
+
5
+ describe CheckResult do
6
+
7
+ describe "#has_errors" do
8
+
9
+ context "when result does not have errors" do
10
+ it "should return false" do
11
+ result = CheckResult.new("url", "achecker_url", 0)
12
+ expect(result.has_errors).to be_falsy
13
+ end
14
+ end
15
+
16
+ context "when result has errors" do
17
+ it "should return true" do
18
+ result = CheckResult.new("url", "achecker_url", 1)
19
+ expect(result.has_errors).to be_truthy
20
+ end
21
+ end
22
+
23
+ end
24
+
25
+ end
26
+
27
+ end
@@ -0,0 +1,30 @@
1
+ require 'spec_helper'
2
+
3
+ module AChecker
4
+
5
+ describe UrlBuilder do
6
+
7
+ let(:id) { "12345" }
8
+ let(:builder) { UrlBuilder.new(id) }
9
+
10
+ describe "#build" do
11
+
12
+ context "when output is rest" do
13
+ it "should set the id" do
14
+ url = builder.build("http://target.url", "rest").to_s
15
+ expect(url).to include("id=#{id}")
16
+ end
17
+ end
18
+
19
+ context "when output is html" do
20
+ it "should not set the id" do
21
+ url = builder.build("http://target.url", "html").to_s
22
+ expect(url).not_to include("id=#{id}")
23
+ end
24
+ end
25
+
26
+ end
27
+
28
+ end
29
+
30
+ end
@@ -0,0 +1,6 @@
1
+ $:.unshift File.dirname(__FILE__) + '/../lib'
2
+
3
+ require 'achecker'
4
+
5
+ RSpec.configure do |config|
6
+ end
metadata ADDED
@@ -0,0 +1,138 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: achecker
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Rafael Magrin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-07-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: nokogiri
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.6'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.6'
41
+ - !ruby/object:Gem::Dependency
42
+ name: webmock
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.18'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.18'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: '3.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: '3.0'
83
+ description: Wrapper for AChecker Web Accessibility Checker
84
+ email:
85
+ - rafael.magrin@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - .gitignore
91
+ - .rspec
92
+ - .travis.yml
93
+ - Gemfile
94
+ - LICENSE.txt
95
+ - README.md
96
+ - Rakefile
97
+ - achecker.gemspec
98
+ - lib/achecker.rb
99
+ - lib/achecker/api.rb
100
+ - lib/achecker/check_result.rb
101
+ - lib/achecker/check_result_builder.rb
102
+ - lib/achecker/url_builder.rb
103
+ - lib/achecker/version.rb
104
+ - spec/achecker/api_spec.rb
105
+ - spec/achecker/check_result_builder_spec.rb
106
+ - spec/achecker/check_result_spec.rb
107
+ - spec/achecker/url_builder_spec.rb
108
+ - spec/spec_helper.rb
109
+ homepage: https://github.com/rmagrin/achecker
110
+ licenses:
111
+ - MIT
112
+ metadata: {}
113
+ post_install_message:
114
+ rdoc_options: []
115
+ require_paths:
116
+ - lib
117
+ required_ruby_version: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - ! '>='
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ required_rubygems_version: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - ! '>='
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
127
+ requirements: []
128
+ rubyforge_project:
129
+ rubygems_version: 2.3.0
130
+ signing_key:
131
+ specification_version: 4
132
+ summary: Wrapper for AChecker Web Accessibility Checker
133
+ test_files:
134
+ - spec/achecker/api_spec.rb
135
+ - spec/achecker/check_result_builder_spec.rb
136
+ - spec/achecker/check_result_spec.rb
137
+ - spec/achecker/url_builder_spec.rb
138
+ - spec/spec_helper.rb