Sha256: 89eb6af26b6c913c72abb6f222cdf22ce7777fee05e76ffaaf1d3fcc091c9eba
Contents?: true
Size: 1.23 KB
Versions: 2
Compression:
Stored size: 1.23 KB
Contents
#!/usr/bin/env ruby -s require 'rubygems' $:.unshift(File.expand_path(File.join(File.dirname(__FILE__), "..", 'lib'))) require 'rdf/rdfxml' require 'getoptlong' def parse(input, base) puts RDF::Writer.for($format.to_sym).buffer { |writer| RDF::RDFXML::Reader.new(input, :base_uri => base, :strict => true).each do |statement| writer << statement end } end mode = ARGV.shift raise "Mode must be one of 'parse'" unless mode == "parse" $verbose = false $format = :ntriples base_uri = "http://example.com" input = nil opts = GetoptLong.new( ["--debug", GetoptLong::NO_ARGUMENT], ["--verbose", GetoptLong::NO_ARGUMENT], ["--quiet", GetoptLong::NO_ARGUMENT], ["--format", GetoptLong::REQUIRED_ARGUMENT], ["--execute", "-e", 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 '--execute' then input = arg when '--format' then $format = arg when '--uri' then base_uri = arg end end if ARGV.empty? s = input ? input : $stdin.read parse(StringIO.new(s), base_uri) else ARGV.each do |test_file| parse(File.open(test_file), base_uri) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rdf-rdfxml-0.2.3 | script/parse |
rdf-rdfxml-0.2.2.1 | script/parse |