#!/usr/bin/env ruby -s require 'rubygems' $:.unshift(File.join(File.expand_path(File.dirname(__FILE__)), "..", 'lib')) require 'rdf_context' require 'spec/rdfa_helper' require 'getoptlong' def run_tc(tc) puts "run #{tc.name}" graph = RdfContext::RdfaParser.parse(tc.input, tc.informationResourceInput, :strict => $strict, :version => tc.version) puts graph.serialize(:format => $format.to_sym, :base => tc.informationResourceInput) unless $quiet end $verbose = false $format = :ntriples $strict = false suite = "xhtml" opts = GetoptLong.new( ["--debug", GetoptLong::NO_ARGUMENT], ["--verbose", GetoptLong::NO_ARGUMENT], ["--quiet", GetoptLong::NO_ARGUMENT], ["--suite", GetoptLong::OPTIONAL_ARGUMENT], ["--strict", GetoptLong::NO_ARGUMENT], ["--format", GetoptLong::REQUIRED_ARGUMENT] ) opts.each do |opt, arg| case opt when '--verbose' then $verbose = true when '--quiet' then $quiet = true when '--debug' then ::RdfContext::debug = true when '--format' then $format = arg when '--suite' then suite = arg when '--strict' then $strict = true end end test_cases = RdfaHelper::TestCase.test_cases(suite) puts test_cases.length test_cases = test_cases.detect do |tc| next unless ARGV.empty? || ARGV.any? {|n| tc.name.match(/#{n}/)} run_tc(tc) end