In this example SimpleCrawler can be used to crawl a website, test each page with the Ruby Accessibility Analysis Kit and format the result with Ruport. Please note that you must have a working installation of the Ruby programming language and the RubyGems package manager to use this code.
To be able to run this script you will need to install the simplecrawler, raakt and ruport gems first:
gem install simplecrawler gem install raakt gem install ruport
Answer yes to install all the required dependencies. Then, copy the code below to a file and save it e.g. as “test.rb”. Run it from the command line by typing ruby test.rb http://www.example.com.
Please note that Ruport has features to group data and output the result in a variety of formats including PDF. Please see the Ruport documentation for more information.
require 'rubygems' require 'simplecrawler' require 'raakt' require 'ruport' # Set up a new crawler sc = SimpleCrawler::Crawler.new(ARGV[0]) sc.skip_patterns = ["\\.doc$", "\\.pdf$", "\\.xls$", "\\.pdf$", "\\.zip$"] sc.maxcount = 100 report_data = Ruport::Data::Table.new :column_names => ["Url", "Error", "Details"] sc.crawl { |document| if document.http_status and document.http_status[0] = "200" # Run basic accessibility check raakt = Raakt::Test.new(document.data) result = raakt.all puts "#{result.length}\t#{document.uri}" if result.length > 0 for error in result report_data << [document.uri, error.eid.to_s, error.text] end end else #report broken link report_data << [document.uri, "broken_link", ""] end } #write report data to file (HTML table only...) File.open("result.htm", "w") do |file| file << report_data.to_html end