raakt 0.5.5 → 0.5.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,2 @@
1
+ v0.5.6. Updating to new version of Rubygems to make installation simpler. Docs
2
+ fixes (Oh _why where are you?). No new functionality.
data/LICENSE ADDED
@@ -0,0 +1,11 @@
1
+
2
+ Copyright (c) 2007, Peter Krantz (http://www.peterkrantz.com)
3
+ All rights reserved.
4
+
5
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6
+
7
+ * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
8
+ * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
9
+ * Neither the name of Peter Krantz nor the names of contributors may be used to endorse or promote products derived from this software without specific prior written permission.
10
+
11
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,102 @@
1
+ CHANGELOG
2
+ LICENSE
3
+ Manifest
4
+ README
5
+ TODO
6
+ examples/acctest.rb
7
+ examples/crawlandtest.rb
8
+ examples/list_site_urls.rb
9
+ examples/seleniumrc_example.rb
10
+ examples/svarta_listan.rb
11
+ examples/watir_example.rb
12
+ lib/iso_language_codes.rb
13
+ lib/raakt.rb
14
+ raakt.gemspec
15
+ rakefile
16
+ service/files/base.css
17
+ service/files/button-left.png
18
+ service/files/button-right.png
19
+ service/files/grad.png
20
+ service/files/jquery-131.js
21
+ service/files/round-br.png
22
+ service/files/round-tl.png
23
+ service/files/round-tr.png
24
+ service/files/tab-tl.png
25
+ service/files/tab-tr.png
26
+ service/files/test.js
27
+ service/files/textbg.png
28
+ service/files/w3c.png
29
+ service/index.rhtml
30
+ service/server.rb
31
+ tests/areadoc1.htm
32
+ tests/areadoc2.htm
33
+ tests/areadoc3.htm
34
+ tests/bdoc.htm
35
+ tests/charset_nocharset_specified.htm
36
+ tests/charset_utf8.htm
37
+ tests/difficult_words1.htm
38
+ tests/difficult_words2.htm
39
+ tests/difficult_words3.htm
40
+ tests/difficult_words4.htm
41
+ tests/difficult_words5.htm
42
+ tests/difficult_words6.htm
43
+ tests/difficult_words7.htm
44
+ tests/embeddoc1.htm
45
+ tests/empty.htm
46
+ tests/emptytitledoc.htm
47
+ tests/fielddoc1.htm
48
+ tests/fielddoc2.htm
49
+ tests/fielddoc3.htm
50
+ tests/flickerdoc1.htm
51
+ tests/formdoc1.htm
52
+ tests/formdoc2.htm
53
+ tests/formdoc3.htm
54
+ tests/framedoc1.htm
55
+ tests/framedoc2.htm
56
+ tests/full_berg.htm
57
+ tests/full_google.htm
58
+ tests/headingsdoc1.htm
59
+ tests/headingsdoc10.htm
60
+ tests/headingsdoc2.htm
61
+ tests/headingsdoc3.htm
62
+ tests/headingsdoc4.htm
63
+ tests/headingsdoc5.htm
64
+ tests/headingsdoc6.htm
65
+ tests/headingsdoc7.htm
66
+ tests/headingsdoc8.htm
67
+ tests/headingsdoc9.htm
68
+ tests/imagedoc1.htm
69
+ tests/imagedoc2.htm
70
+ tests/imagedoc3.htm
71
+ tests/imagedoc4.htm
72
+ tests/inputimgdoc1.htm
73
+ tests/invalidelements1.htm
74
+ tests/invalidhtmldoc1.htm
75
+ tests/invalidhtmldoc2.htm
76
+ tests/invalidxhtmldoc1.htm
77
+ tests/langinfodoc1.htm
78
+ tests/langinfodoc2.htm
79
+ tests/linkdoc1.htm
80
+ tests/linkdoc2.htm
81
+ tests/linkdoc3.htm
82
+ tests/linkdoc4.htm
83
+ tests/metarefreshdoc1.htm
84
+ tests/metarefreshdoc2.htm
85
+ tests/metarefreshdoc3.htm
86
+ tests/nestedcomment.htm
87
+ tests/nestedtabledoc.htm
88
+ tests/newlinetext.txt
89
+ tests/raakt_test.rb
90
+ tests/scriptdoc1.htm
91
+ tests/scriptdoc2.htm
92
+ tests/tabledoc1.htm
93
+ tests/tabledoc2.htm
94
+ tests/tabledoc3.htm
95
+ tests/tabledoc4.htm
96
+ tests/tabledoc5.htm
97
+ tests/tabledoc6.htm
98
+ tests/tabledoc7.htm
99
+ tests/tablelayoutdoc.htm
100
+ tests/test_helper.rb
101
+ tests/xhtmldoc1.htm
102
+ Rakefile
data/README ADDED
@@ -0,0 +1,83 @@
1
+
2
+ RAAKT - The Ruby Accessibility Analysis Kit
3
+
4
+ Copyright (c) 2006, Peter Krantz (http://www.peterkrantz.com)
5
+ All rights reserved.
6
+
7
+ License: See LICENSE file.
8
+
9
+ RAAKT is a toolkit to find accessibility issues in HTML documents. RAAKT can be used as part of a an automatic test procedure or as a standalone module for mass validation of all pages in a site. RAAKT is based on PAAKT the Python Accessibility Analysis Kit.
10
+
11
+ The following checks are done:
12
+
13
+ check_document_structure
14
+ check_tables
15
+ check_for_formatting_elements
16
+ check_has_heading
17
+ check_form
18
+ check_link_text
19
+ check_title
20
+ check_frames
21
+ check_images
22
+ check_refresh
23
+ check_for_nested_tables
24
+ check_for_language_info
25
+
26
+ RAAKT output is in the form of an array of error message objects. An error message object has an id which can be used to find out more about the specific error.
27
+
28
+ To run unit tests for raakt, see the raakt_test.rb file in the tests folder. Some of the tests access remote documents over the internet. To include remote tests, run the test suite with the "includeremote" parameter:
29
+
30
+ > ruby raakt_test.rb includeremote
31
+
32
+
33
+ CONTRIBUTIONS
34
+
35
+ Patch to use hpricot by Derek Perrault.
36
+
37
+ MORE INFO
38
+
39
+ For more information about RAAKT, please contact peter dot krantz at gmail dot com or see http://peterkrantz.com/projects/raakt
40
+
41
+ To use RAAKT as a command line tool (see acctest.rb in the examples dir of the installed gem):
42
+
43
+
44
+ # This is a sample command line script that uses the raakt gem to test a html document.
45
+ require 'rubygems'
46
+ require 'net/http'
47
+ require 'uri'
48
+ require 'raakt'
49
+
50
+ #Parse command line url argument
51
+ url = ARGV[0] || ""
52
+
53
+ if url.length == 0
54
+ puts "\nRuby Accessibility Analysis Kit\n\n Usage: raakt <url>\n Example: raakt http://www.rubylang.org/en"
55
+ return
56
+ else
57
+ #Clean the url and make sure protocol and trailing slash is available
58
+ url = "http://" + url unless url[0..3] == "http"
59
+ end
60
+
61
+ #Get html for the url specified (does not follow redirects)
62
+ puts "Fetching #{url}...\n"
63
+ uri = URI.parse(url)
64
+ res = Net::HTTP.start(uri.host, uri.port) {|http|
65
+ http.get(uri.path)
66
+ }
67
+
68
+ # Set up the RAAKT test
69
+ raakttest = Raakt::Test.new(res.body)
70
+
71
+ #Run all checks and print result to the console
72
+ result = raakttest.all
73
+
74
+ if result.length > 0
75
+ puts "Accessibility problems detected:"
76
+ puts result
77
+ else
78
+ puts "No measurable accessibility problems were detected."
79
+ end
80
+
81
+
82
+
83
+
@@ -0,0 +1,18 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'echoe'
4
+
5
+ Echoe.new('raakt') do |s|
6
+ s.name = 'raakt'
7
+ s.summary = 'A toolkit to find basic accessibility issues in HTML documents.'
8
+ s.runtime_dependencies = ["hpricot >=0.6"]
9
+ s.has_rdoc = true
10
+ s.ruby_version = '>= 1.8.2'
11
+ s.files = FileList['lib/*.rb', 'tests/*'].to_a
12
+ s.test_files = Dir.glob('tests/raakt_test.rb')
13
+ s.author = "Peter Krantz"
14
+ s.email = "peter.krantzNODAMNSPAM@gmail.com"
15
+ s.url = "http://www.peterkrantz.com/raakt/wiki/"
16
+ s.ignore_pattern = ["examples", "pkg", "service"]
17
+ end
18
+
data/TODO ADDED
@@ -0,0 +1,9 @@
1
+ TODO
2
+ ----
3
+ - Standalone web server interface for local testing
4
+ - check for xml:lang as well
5
+
6
+
7
+ DONE
8
+ ----
9
+ - Pluggable wordlist support to find diffcult words that should be avoided (e.g. "svarta listan" for Swedish)
@@ -0,0 +1,42 @@
1
+ # This is a sample command line script that uses the raakt gem to test a html document. Please install the mechanize gem before running this script.
2
+ require 'mechanize'
3
+ require File.dirname(__FILE__) + '/../lib/raakt' #or just 'raakt' of you have installed the gem
4
+
5
+ #Parse command line url argument to get URL
6
+ url = ARGV[0] || ""
7
+
8
+ if url.length == 0
9
+ puts "\nRuby Accessibility Analysis Kit Example\n\n Usage: ruby acctest.rb <url>\n Example: ruby acctest.rb http://www.rubylang.org/en\n\nView source for this file for example usage."
10
+ exit
11
+ end
12
+
13
+ #Get html for the url specified (does not follow redirects)
14
+ puts "Fetching #{url}...\n"
15
+
16
+ #Allow for bastard-sized asp.net view state attribute values...
17
+ Hpricot.buffer_size = 262144
18
+
19
+ #Set up mechanize agent
20
+ agent = WWW::Mechanize.new
21
+ agent.pluggable_parser.default = Hpricot
22
+
23
+ # Set user_agent string
24
+ # See possible values here:
25
+ # http://mechanize.rubyforge.org/classes/WWW/Mechanize.html#constants-list
26
+ agent.user_agent_alias = 'Mac Safari'
27
+
28
+ # Get the page
29
+ page = agent.get(url)
30
+
31
+ # Set up the RAAKT test and pass html and headers
32
+ raakttest = Raakt::Test.new(page.body, page.header.to_hash)
33
+
34
+ #Run all checks and print result to the console
35
+ result = raakttest.all
36
+
37
+ if result.length > 0
38
+ puts "Accessibility problems detected:"
39
+ puts result
40
+ else
41
+ puts "No measurable accessibility problems were detected."
42
+ end
@@ -0,0 +1,64 @@
1
+ require 'net/http'
2
+ require 'uri'
3
+
4
+ class SiteCrawler
5
+
6
+ def initialize(url)
7
+ @site_uri = URI.parse(url)
8
+ @site_uri.path = "/" if @site_uri.path == ""
9
+ @visited = Hash.new
10
+ @queue = Array.new
11
+ addPath(@site_uri.path)
12
+ puts "Initialized site crawl for #{@site_uri}"
13
+ end
14
+
15
+
16
+ def addPath(path)
17
+ @queue.push path
18
+ @visited[path] = false
19
+ end
20
+
21
+
22
+ def getPage(path)
23
+ begin
24
+ uri = @site_uri.clone
25
+ uri.path = uri.path + path if path != "/"
26
+ puts "getting #{uri}"
27
+ response = Net::HTTP.get_response(uri)
28
+ rescue Exception
29
+ puts "Error: #{$!}"
30
+ return ""
31
+ end
32
+ return response.body
33
+ end
34
+
35
+
36
+ def queueLocalLinks(html)
37
+ html.scan(/<a href\s*=\s*["']([^"]+)"/i) {|w|
38
+ uri = URI.parse("#{w}")
39
+ if !@visited.has_key?(uri.path) and (uri.relative? or uri.host == @site_uri.host)
40
+ addPath(uri.path)
41
+ end
42
+ }
43
+ end
44
+
45
+
46
+ def crawlSite()
47
+ while (!@queue.empty?)
48
+ uri = @queue.shift
49
+ page = getPage(uri)
50
+ yield uri, page
51
+ queueLocalLinks(page)
52
+ @visited[uri] = true
53
+ end
54
+ end
55
+ end
56
+
57
+
58
+ sc = SiteCrawler.new(ARGV[0])
59
+ @pages = Array.new
60
+ sc.crawlSite { |url, page_text|
61
+ puts url
62
+ @pages << url
63
+ # SITE_INDEX <<{ :url => url, :context => page_text }
64
+ }
@@ -0,0 +1,12 @@
1
+ require '../lib/simplecrawler.rb'
2
+
3
+ # Set up a new crawler
4
+ sc = SimpleCrawler::Crawler.new(ARGV[0])
5
+ sc.skip_patterns = ["\\.doc$", "\\.pdf$", "\\.xls$", "\\.pdf$", "\\.zip$"]
6
+
7
+ sc.crawl { |document|
8
+
9
+ # List links for entire site
10
+ puts document.uri
11
+
12
+ }
@@ -0,0 +1,21 @@
1
+ require 'spec'
2
+ require 'selenium'
3
+ require 'raakt'
4
+
5
+ context 'Test Google' do
6
+ setup do
7
+ @sel = Selenium::SeleniumDriver.new("localhost", 4444, "*iexplore", "http://www.google.com", 15000)
8
+ @sel.start
9
+ end
10
+
11
+ specify'assert start page accessibility' do
12
+ @sel.open("http://www.google.com/webhp")
13
+ raakttest = Raakt::Test.new(@sel.get_html_source)
14
+ result = raakttest.all
15
+ result.should be([])
16
+ end
17
+
18
+ teardown do
19
+ @sel.stop
20
+ end
21
+ end
@@ -0,0 +1,100 @@
1
+ # This is an example wordlist to use with the check_difficult_words test.
2
+ # It is in the form of a hash where the key is the phrase to look for and the value
3
+ # is the recommended alternative word/phrase.
4
+ #
5
+ # In swedish: Denna ordlista är baserad på "Svarta listan- Ord och fraser
6
+ # som kan ersättas i författningsspråk". Ordlistan ges ut av rättschefen
7
+ # i Statsrådsberedningen och har utarbetats av språkexperterna på
8
+ # Justitiedepartementets granskningsenhet.
9
+ #
10
+ # För mer information se: http://www.regeringen.se/sb/d/243/a/19775
11
+
12
+ SVARTA_LISTAN = {
13
+ "anhängiggöra" => "Skriv hellre 'väcka/inleda'.",
14
+ "anbringa" => "Skriv hellre 'sätta upp/sätta på/placera/fästa (på något)'.",
15
+ "anmana" => "Skriv hellre 'uppmana'.",
16
+ "anmaning" => "Skriv hellre 'uppmaning'.",
17
+ "anmoda" => "Skriv hellre 'uppmana'.",
18
+ "anmodan" => "Skriv hellre 'uppmaning'.",
19
+ "anmodas" => "Skriv hellre 'uppmanas'.",
20
+ "avbida" => "Skriv hellre 'invänta/vänta (på)/avvakta'.",
21
+ "avbidan" => "Skriv hellre 'väntan'.",
22
+ "avge" => "Skriv hellre 'ge (bud), lämna (anbud, rapport m.m.)'.",
23
+ "avnämare" => "Skriv hellre 'användare/mottagare/konsument/kund'.",
24
+ "avskrift" => "Skriv hellre 'kopia'.",
25
+ "avsända" => "Skriv hellre 'sända/skicka (i väg)'.",
26
+ "belägen" => "Skriv hellre 'ligger (i)'.",
27
+ "bereda" => "Skriv hellre 'ge/låta'.",
28
+ "beskaffenhet" => "Skriv hellre 'art/slag/sort'.",
29
+ "utan dröjsmål" => "Skriv hellre 'genast/omedelbart/snarast/möjligt'.",
30
+ "därvid" => "Skriv hellre 'då/i det sammanhanget'.",
31
+ "efterkomma" => "Skriv hellre 'lyda/följa'.",
32
+ "efterlevas" => "Skriv hellre 'följas'.",
33
+ "eljest" => "Skriv hellre 'annars/annat/på annat sätt/av andra skäl/i övrigt/av någon annan anledning'.",
34
+ "envar" => "Skriv hellre 'var och en'.",
35
+ "ettvart" => "Skriv hellre 'vart och ett'.",
36
+ "erfara" => "Skriv hellre 'få veta'.",
37
+ "erfordra" => "Skriv hellre 'behövs/krävs/är nödvändigt'.",
38
+ "erfordras" => "Skriv hellre 'behövs/krävs/är nödvändigt'.",
39
+ "erforderliga" => "Skriv hellre 'behövs/krävs/är nödvändigt'.",
40
+ "erforderlig" => "Skriv hellre 'nödvändig/tillräcklig'.",
41
+ "erhålla" => "Skriv hellre 'få'.",
42
+ "erinran" => "Skriv hellre 'upplysning (om)'.",
43
+ "erinra" => "Skriv hellre 'invända'.",
44
+ "erlägga" => "Skriv hellre 'betala'.",
45
+ "foga" => "Skriv hellre 'lämna (in) (tillsammans med)'.",
46
+ "föranleda" => "Skriv hellre 'det finns'.",
47
+ "föranleder" => "Skriv hellre 'det finns'.",
48
+ "föranstalta" => "Skriv hellre 'ordna så/ordna med/sörja för/se till'.",
49
+ "förebringa" => "Skriv hellre 'lägga fram/lämna'.",
50
+ "föreligga" => "Skriv hellre 'finnas'.",
51
+ "föreligger" => "Skriv hellre 'det finns'.",
52
+ "företa" => "Skriv hellre 'göra'.",
53
+ "förete" => "Skriv hellre 'visa (upp)'.",
54
+ "förfaller till betalning" => "Skriv hellre '(senast) skall betalas'.",
55
+ "förfara" => "Skriv hellre '(skall) göra'.",
56
+ "förflutit" => "Skriv hellre 'det har gått'.",
57
+ "förordna" => "Skriv hellre 'besluta/bestämma/utse'.",
58
+ "försorg" => "Skriv hellre 'se till att'.",
59
+ "förutskicka" => "Skriv hellre 'meddela på förhand/i förväg'.",
60
+ "handha" => "Skriv hellre 'ha hand om/sköta'.",
61
+ "hemställa" => "Skriv hellre 'begära/föreslå'.",
62
+ "hörsamma" => "Skriv hellre 'följa/lyda/rätta sig efter'.",
63
+ "ikläda" => "Skriv hellre 'ta på'.",
64
+ "inhämta" => "Skriv hellre 'skaffa'.",
65
+ "inkomma med" => "Skriv hellre 'lämna in/skicka in/sända över'.",
66
+ "jämförlig" => "Skriv hellre 'liknande'.",
67
+ "jämka" => "Skriv hellre 'sänka/minska/sätta ned/ner/(för)ändra'.",
68
+ "lagfaren" => "Skriv hellre 'vara jurist/som avlagt jur.kand. examen/med jur.kand.-examen'.",
69
+ "lagrum" => "Skriv hellre 'bestämmelse/paragraf'.",
70
+ "lända till förfång" => "Skriv hellre 'skada/vara till skada'.",
71
+ "medge anstånd" => "Skriv hellre 'bevilja anstånd'.",
72
+ "nyttja" => "Skriv hellre 'använda'.",
73
+ "nöjaktig" => "Skriv hellre 'godtagbar/som får godtas'.",
74
+ "olägenhet" => "Skriv hellre 'besvär/problem'.",
75
+ "oundgänglig" => "Skriv hellre 'nödvändig/absolut'.",
76
+ "påkalla" => "Skriv hellre 'begära/kräva'.",
77
+ "utom riket" => "Skriv hellre 'utomlands/utanför Sverige'.",
78
+ "rådrum" => "Skriv hellre 'tid (på sig)'.",
79
+ "stadfästa" => "Skriv hellre 'godkänna, fastställa, bekräfta'.",
80
+ "stadgas" => "Skriv hellre 'föreskrivs'.",
81
+ "såvitt avser" => "Skriv hellre 'när det gäller/i fråga om'.",
82
+ "tillkommer" => "Skriv hellre 'har'.",
83
+ "tillskapa" => "Skriv hellre 'bilda, inrätta, skapa'.",
84
+ "tillställa" => "Skriv hellre 'lämna/ge/sända/skicka till'.",
85
+ "tillställas" => "Skriv hellre 'lämna/ge/sända/skicka till'.",
86
+ "underlåta" => "Skriv hellre 'låta bli/inte'.",
87
+ "uppbära" => "Skriv hellre 'få/ha'.",
88
+ "ersättning utgår" => "Skriv hellre 'ersättningen betalas (ut)/lämnas'.",
89
+ "utröna" => "Skriv hellre 'ta reda på/klarlägga'.",
90
+ "vederlag" => "Skriv hellre 'ersättning/motprestation'.",
91
+ "ådöma" => "Skriv hellre 'döma till/döma ut'.",
92
+ "ådömas" => "Skriv hellre 'dömas till/dömas ut'.",
93
+ "åligger" => "Skriv hellre 'är skyldig (att)/skall/har'.",
94
+ "åligganden" => "Skriv hellre 'skyldigheter'.",
95
+ "åsätta" => "Skriv hellre 'fastställa'.",
96
+ "åsatts" => "Skriv hellre 'fastställts'.",
97
+ "åtnjuta" => "Skriv hellre 'få/ha/beviljas'.",
98
+ "åtnjuter" => "Skriv hellre 'har'.",
99
+ "åtnjutit" => "Skriv hellre 'fått'.",
100
+ }