Sha256: 4b668f40696994c92bccda5c289d53caf36b586a7833aa47c3fdb0fbb55d26b8
Contents?: true
Size: 1.32 KB
Versions: 4
Compression:
Stored size: 1.32 KB
Contents
#!/usr/bin/env ruby -s 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 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], ["--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 '--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
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
rdfa_parser-0.1.5 | bin/rdfa_parser |
rdfa_parser-0.1.3 | bin/rdfa_parser |
rdfa_parser-0.1.1 | bin/rdfa_parser |
rdfa_parser-0.1.0 | bin/rdfa_parser |