instead of .
- #
- # Locals: subject, typeof, predicates, rel, element, inlist, attr_props
- # Yield: predicates.each
- subject: %q(
- - first_type, *types = typeof.to_s.split(' ')
- - (types.unshift(first_type); first_type = nil) if first_type && (first_type.include?('/') || first_type.start_with?('_:'))
- - first_type ||= get_qname(RDF.Description)
- - first_type = first_type[1..-1] if first_type.to_s.start_with?(":")
- - attr_props = attr_props.merge(get_qname(RDF.nodeID) => subject.id) if subject.node? && ref_count(subject) >= 1
- - attr_props = attr_props.merge(get_qname(RDF.about) => relativize(subject)) if subject.uri?
- - haml_tag(first_type, attr_props) do
- - types.each do |type|
- - expanded_type = expand_curie(type)
- - if expanded_type.start_with?('_:')
- - haml_tag(get_qname(RDF.type), "rdf:nodeID" => expanded_type[2..-1])
- -else
- - haml_tag(get_qname(RDF.type), "rdf:resource" => expanded_type)
- - predicates.each do |p|
- = yield(p)
- ),
-
- # Output for single-valued properties
- # Locals: predicate, object, inlist
- # Yields: object
- # If nil is returned, render as a leaf
- # Otherwise, render result
- property_value: %q(
- - if recurse && res = yield(object)
- - haml_tag(property) do
- = res
- - elsif object.literal? && object.datatype == RDF.XMLLiteral
- - haml_tag(property, :"<", "rdf:parseType" => "Literal") do
- = object.value
- - elsif object.literal?
- - haml_tag(property, :"<", "xml:lang" => object.language, "rdf:datatype" => (object.datatype unless object.plain?)) do
- = object.value.to_s.encode(xml: :text)
- - elsif object.node?
- - haml_tag(property, :"/", "rdf:nodeID" => object.id)
- - else
- - haml_tag(property, :"/", "rdf:resource" => relativize(object))
- ),
-
- # Outpust for a list
- # Locals: predicate, list
- # Yields: object
- # If nil is returned, render as a leaf
- # Otherwise, render result
- collection: %q(
- - haml_tag(property, get_qname(RDF.parseType) => "Collection") do
- - list.each do |object|
- - if recurse && res = yield(object)
- = res
- - elsif object.node?
- - haml_tag(get_qname(RDF.Description), :"/", "rdf:nodeID" => (object.id if ref_count(object) > 1))
- - else
- - haml_tag(get_qname(RDF.Description), :"/", "rdf:about" => relativize(object))
- ),
- }
- HAML_TEMPLATES = {base: BASE_HAML}
- DEFAULT_HAML = BASE_HAML
- end
-end
\ No newline at end of file
diff --git a/rdf-rdfxml.gemspec b/rdf-rdfxml.gemspec
index 586b641..016c070 100755
--- a/rdf-rdfxml.gemspec
+++ b/rdf-rdfxml.gemspec
@@ -30,9 +30,8 @@ Gem::Specification.new do |gem|
gem.add_runtime_dependency 'rdf', '~> 3.2'
gem.add_runtime_dependency 'rdf-xsd', '~> 3.2'
- gem.add_runtime_dependency 'rdf-rdfa', '~> 3.2'
gem.add_runtime_dependency 'htmlentities', '~> 4.3'
- gem.add_runtime_dependency 'haml', '~> 5.2' # Until workaround for haml_tag is found.
+ gem.add_runtime_dependency 'builder', '~> 3.2'
gem.add_development_dependency 'json-ld', '>= 3.2'
gem.add_development_dependency 'rspec', '~> 3.10'
diff --git a/script/parse b/script/parse
index 112df5f..9697894 100755
--- a/script/parse
+++ b/script/parse
@@ -5,7 +5,6 @@ require "bundler/setup"
require 'rdf/rdfxml'
require 'rdf/turtle'
require 'rdf/ntriples'
-require 'rdf/ordered_repo'
require 'getoptlong'
require 'logger'
@@ -34,7 +33,7 @@ def run(input, **options)
end
else
r = reader_class.new(input, **options[:parser_options])
- g = RDF::OrderedRepo.new << r
+ g = RDF::Repository.new << r
num = g.count
options[:output].puts g.dump(options[:output_format], prefixes: r.prefixes, **options[:writer_options])
end
diff --git a/script/tc b/script/tc
index 6656c89..ed28deb 100755
--- a/script/tc
+++ b/script/tc
@@ -31,21 +31,23 @@ def earl_preamble(options)
end
def run_tc(tc, **options)
- STDERR.write "run #{tc.name}"
+ STDERR.write "run #{tc.name} "
if options[:verbose]
puts "\nTestCase: #{tc.inspect}"
- puts "\nInput:\n" + tc.input.read
- puts "\nExpected:\n" + tc.expected.read
- tc.input.rewind
- tc.expected.rewind
+ puts "\nInput:\n" + tc.input
+ puts "\nExpected:\n" + tc.expected
end
begin
puts "open #{tc.action}" if options[:verbose]
- options = {base_uri: tc.base}.merge(options)
+ options = {
+ base_uri: tc.base,
+ validate: tc.syntax?,
+ logger: tc.logger
+ }.merge(options)
- reader = RDF::Reader.for(tc.action).new(tc.input, base_uri: tc.base, validate: tc.syntax?, logger: options[:logger])
+ reader = RDF::Reader.for(tc.action).new(tc.input, **options)
graph = RDF::Repository.new
result = nil
@@ -86,7 +88,7 @@ def run_tc(tc, **options)
end
end
- options[:output].puts("\nOutput:\n" + graph.dump(:ntriples, validate: false)) unless options[:quiet]
+ options[:output].puts("\nOutput:\n" + graph.dump(:ntriples, validate: false)) if options[:verbose]
if options[:earl]
options[:output].puts %{
@@ -149,16 +151,20 @@ opts.each do |opt, arg|
end
end
-manifest = Fixtures::SuiteTest::BASE + "manifest.ttl"
+manifests = [Fixtures::SuiteTest::BASE + "rdf11/rdf-xml/"].map {|m| "#{m}manifest.ttl"}
earl_preamble(options) if options[:earl]
result_count = {}
-Fixtures::SuiteTest::Manifest.open(manifest) do |m|
- m.entries.each do |tc|
- next unless ARGV.empty? || ARGV.any? {|n| tc.name.match(/#{n}/)}
- run_tc(tc, options.merge(result_count: result_count))
+begin
+ manifests.each do |manifest|
+ Fixtures::SuiteTest::Manifest.open(manifest) do |m|
+ m.entries.each do |tc|
+ next unless ARGV.empty? || ARGV.any? {|n| tc.name.match(/#{n}/)}
+ run_tc(tc, result_count: result_count, **options)
+ end
+ end
end
end
diff --git a/spec/.gitignore b/spec/.gitignore
index a4cc2ca..1dbd86d 100644
--- a/spec/.gitignore
+++ b/spec/.gitignore
@@ -1 +1,2 @@
/uri-cache/
+/w3c-rdf-tests
diff --git a/spec/reader_spec.rb b/spec/reader_spec.rb
index 769f787..f14ab1d 100644
--- a/spec/reader_spec.rb
+++ b/spec/reader_spec.rb
@@ -242,7 +242,7 @@
)
expect do
- graph = parse(sampledoc, base_uri: "http://example.com", validate: true)
+ parse(sampledoc, base_uri: "http://example.com", validate: true)
end.to raise_error(RDF::ReaderError)
expect(logger.to_s).to match(/Obsolete attribute .*aboutEach/)
end
@@ -264,7 +264,7 @@
)
expect do
- graph = parse(sampledoc, base_uri: "http://example.com", validate: true)
+ parse(sampledoc, base_uri: "http://example.com", validate: true)
end.to raise_error(RDF::ReaderError)
expect(logger.to_s).to match(/Obsolete attribute .*aboutEachPrefix/)
end
@@ -276,7 +276,7 @@
)
expect do
- graph = parse(sampledoc, base_uri: "http://example.com", validate: true)
+ parse(sampledoc, base_uri: "http://example.com", validate: true)
end.to raise_error(RDF::ReaderError)
expect(logger.to_s).to match(/ID addtribute '.*' must be a NCName/)
end
@@ -291,7 +291,7 @@
)
expect do
- graph = parse(sampledoc, base_uri: "http://example.com", validate: true)
+ parse(sampledoc, base_uri: "http://example.com", validate: true)
end.to raise_error(RDF::ReaderError)
expect(logger.to_s).to match(/ID addtribute '.*' must be a NCName/)
end
@@ -304,7 +304,7 @@
)
expect do
- graph = parse(sampledoc, base_uri: "http://example.com", validate: true)
+ parse(sampledoc, base_uri: "http://example.com", validate: true)
end.to raise_error(RDF::ReaderError)
expect(logger.to_s).to include("ID addtribute 'a/b' must be a NCName")
end
@@ -316,7 +316,7 @@
)
expect do
- graph = parse(sampledoc, base_uri: "http://example.com", validate: true)
+ parse(sampledoc, base_uri: "http://example.com", validate: true)
end.to raise_error(RDF::ReaderError)
expect(logger.to_s).to match(/Obsolete attribute .*bagID/)
end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index bc905ac..e57f387 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -11,7 +11,7 @@
require 'matchers'
begin
require 'nokogiri'
-rescue LoadError => e
+rescue LoadError
:rexml
end
begin
@@ -29,11 +29,10 @@
])
SimpleCov.start do
add_filter "/spec/"
- add_filter "/lib/rdf/rdfa/reader/rexml.rb"
- add_filter "/lib/rdf/rdfa/context.rb"
end
rescue LoadError
end
+
require 'rdf/rdfxml'
::RSpec.configure do |c|
diff --git a/spec/suite_helper.rb b/spec/suite_helper.rb
index 6fda920..ef76ac7 100644
--- a/spec/suite_helper.rb
+++ b/spec/suite_helper.rb
@@ -6,8 +6,8 @@
# For now, override RDF::Utils::File.open_file to look for the file locally before attempting to retrieve it
module RDF::Util
module File
- REMOTE_PATH = "http://www.w3.org/2013/RDFXMLTests/"
- LOCAL_PATH = ::File.expand_path("../w3c-rdf/rdf-xml", __FILE__) + '/'
+ REMOTE_PATH = "https://w3c.github.io/rdf-tests/rdf/"
+ LOCAL_PATH = ::File.expand_path("../w3c-rdf-tests/rdf/", __FILE__) + '/'
class << self
alias_method :original_open_file, :open_file
@@ -72,7 +72,7 @@ def self.open_file(filename_or_url, **options, &block)
module Fixtures
module SuiteTest
- BASE = "http://www.w3.org/2013/RDFXMLTests/"
+ BASE = "https://w3c.github.io/rdf-tests/rdf/"
FRAME = JSON.parse(%q({
"@context": {
"xsd": "http://www.w3.org/2001/XMLSchema#",
@@ -124,7 +124,7 @@ class Entry < JSON::LD::Resource
attr_accessor :logger
def base
- "http://www.w3.org/2013/RDFXMLTests/" + action.split('/')[-2,2].join("/")
+ RDF::URI(action)
end
# Alias data and query
diff --git a/spec/suite_spec.rb b/spec/suite_spec.rb
index 7cb5803..8993e41 100644
--- a/spec/suite_spec.rb
+++ b/spec/suite_spec.rb
@@ -6,7 +6,7 @@
describe "w3c rdfcore tests" do
require_relative 'suite_helper'
- %w(manifest.ttl).each do |man|
+ %w(rdf11/rdf-xml/manifest.ttl).each do |man|
Fixtures::SuiteTest::Manifest.open(Fixtures::SuiteTest::BASE + man) do |m|
describe m.comment do
m.entries.each do |t|
diff --git a/spec/writer_spec.rb b/spec/writer_spec.rb
index e5da3c3..95ab7ac 100644
--- a/spec/writer_spec.rb
+++ b/spec/writer_spec.rb
@@ -8,7 +8,7 @@ class FOO < RDF::Vocabulary("http://foo/"); end
describe "RDF::RDFXML::Writer" do
let(:logger) {RDF::Spec.logger}
it_behaves_like 'an RDF::Writer' do
- let(:writer) {RDF::RDFXML::Writer.new}
+ let(:writer) {RDF::RDFXML::Writer.new(::StringIO.new)}
end
describe "#buffer" do
@@ -517,13 +517,13 @@ class FOO < RDF::Vocabulary("http://foo/"); end
end
end
- specify { expect(subject).to match / "http://foo/"})
+ serialize(nt, prefixes: {"" => "http://foo/"})
end
{
@@ -534,8 +534,8 @@ class FOO < RDF::Vocabulary("http://foo/"); end
end
end
- specify { expect(subject).to match /