Sha256: 89a8fa477a05bddf75a5332ccd1d0310b9b2ac46370f9be924f3b4114d626468
Contents?: true
Size: 1.21 KB
Versions: 3
Compression:
Stored size: 1.21 KB
Contents
#!/usr/bin/env ruby -s require 'rubygems' $:.unshift(File.join(File.dirname(__FILE__), "..", 'lib')) require 'rdf/n3' require 'getoptlong' def parse(input, base) puts RDF::Writer.for($format.to_sym).buffer { |writer| RDF::N3::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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
rdf-n3-0.2.1 | script/parse |
rdf-n3-0.0.3 | script/parse |
rdf-n3-0.0.2 | script/parse |