Sha256: 23e7e14ca08c9dd07c1ff7e97dbeb35ed40cb4c668045ed53ee76edc805d65a6
Contents?: true
Size: 1.51 KB
Versions: 1
Compression:
Stored size: 1.51 KB
Contents
#!/usr/bin/env ruby -s # For some reason, options preceeding files are ignored require 'rubygems' require File.expand_path(File.dirname(__FILE__) + "/../lib/rdfa_parser") require 'getoptlong' class Parse def parse(file, base_uri) puts "Parse: #{file}" if $quiet parser = RdfaParser::RdfaParser.new parser.parse(File.read(file), base_uri) output = case $format when "xml" parser.graph.to_rdfxml else parser.graph.to_ntriples end puts output unless $quiet puts parser.debug.join("\n\t") if $verbose rescue RdfaParser::ParserException => e puts "Parse failure: #{e.message}" #puts e.backtrace puts parser.debug if $verbose && parser #raise rescue Exception => e puts "Parser fault: #{e.message}" puts parser.debug if parser && !$quiet raise end end $verbose = false base_uri = "http://example.com" opts = GetoptLong.new( ["--verbose", GetoptLong::NO_ARGUMENT], ["--version", GetoptLong::NO_ARGUMENT], ["--quiet", GetoptLong::NO_ARGUMENT], ["--debug", GetoptLong::NO_ARGUMENT], ["--format", GetoptLong::REQUIRED_ARGUMENT], ["--uri", GetoptLong::REQUIRED_ARGUMENT] ) opts.each do |opt, arg| case opt when '--verbose' then $verbose = true when '--version' puts "version: #{RdfaParser::VERSION}" exit(0) when '--quiet' then $quiet = true when '--debug' then $DEBUG = true when '--format' then $format = arg when '--uri' then base_uri = arg end end x = Parse.new ARGV.each do |test_file| x.parse(test_file, base_uri) end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rdfa_parser-0.1.2 | bin/rdfa_parser |