Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 38 additions & 29 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,9 @@ task index: MANIFESTS.
select {|m| File.exist?(m)}.
map {|m| m.sub(/manifest(.*)\.ttl$/, 'index\1.html')}

CLOBBER.include(MANIFESTS.map {|ttl| ttl.sub(/manifest(.*)\.ttl$/, 'index\1.html')})

MANIFESTS.each do |ttl|
html = ttl.sub(/manifest(.*)\.ttl$/, 'index\1.html')
jsonld = ttl.sub(/\.ttl$/, '.jsonld')
base = 'https://w3c.github.io/rdf-tests/' + ttl.sub('manifest.ttl', '')

# Find frame closest to file
Expand All @@ -123,39 +122,49 @@ MANIFESTS.each do |ttl|
end
frame_path ||= 'manifest-frame.jsonld'

CLOBBER.include(jsonld)
desc "Build #{jsonld}"
file jsonld => [ttl, frame_path] do
puts "Generate #{jsonld}"
frame = JSON.parse(File.read(frame_path))
ctx = {"__GENERATED__"=>"from:_manifest.ttl__do_not_edit_directly", "@base"=>base}
frame["@context"] = ctx.merge(frame["@context"]) # insert pseudo-comment and base at the top of the context

RDF::Reader.open(ttl, base_uri: base) do |reader|
out = JSON::LD::Writer.buffer(frame: frame, base_uri: base, simple_compact_iris: true) do |writer|
writer << reader
end
File.open(jsonld, "w") do |f|
f.write(out)
end
end
end

if template_path
CLOBBER.include(html)
desc "Build #{html}"
file html => [ttl, frame_path, template_path, 'test-map.json'] do
file html => [jsonld, template_path, 'test-map.json'] do
puts "Generate #{html}"
frame, template, man = File.read(frame_path), File.read(template_path), nil
template, man = File.read(template_path), nil

ttl_path, ttl_file = File.dirname(ttl), File.basename(ttl)
Dir.chdir(ttl_path) do
RDF::Reader.open(ttl_file, base_uri: base) do |reader|
out = JSON::LD::Writer.buffer(frame: JSON.parse(frame), base_uri: base, simple_compact_iris: true) do |writer|
writer << reader
end
man = JSON.parse(File.read(jsonld))
if man.key?('@graph')
Kernel.abort "Expected #{jsonld} to not have a single @graph entry"
end

man = JSON.parse(out)
if man.key?('@graph')
Kernel.abort "Expected manifest to not have a single @graph entry"
end
# Fix up test entries
Array(man['entries']).each do |entry|
# Fix results which aren't IRIs
if res = entry['mf:result'] && entry['mf:result']['@value']
entry.delete('mf:result')
entry['result'] = res == 'true'
end

# Fix up test entries
Array(man['entries']).each do |entry|
# Fix results which aren't IRIs
if res = entry['mf:result'] && entry['mf:result']['@value']
entry.delete('mf:result')
entry['result'] = res == 'true'
end

# Fix some empty arrays (rdf-mt)
%w(recognizedDatatypes unrecognizedDatatypes).each do |p|
if entry["mf:#{p}"].is_a?(Hash) && entry["mf:#{p}"]['@list'] == []
entry[p] = []
entry.delete("mf:#{p}")
end
end
# Fix some empty arrays (rdf-mt)
%w(recognizedDatatypes unrecognizedDatatypes).each do |p|
if entry["mf:#{p}"].is_a?(Hash) && entry["mf:#{p}"]['@list'] == []
entry[p] = []
entry.delete("mf:#{p}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be nice to run these normalizations inside of the JSON-LD serialization code to provide more normalized files

end
end
end
Expand Down
49 changes: 49 additions & 0 deletions rdf/rdf11/manifest.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"@context": {
"__GENERATED__": "from:_manifest.ttl__do_not_edit_directly",
"@base": "https://w3c.github.io/rdf-tests/rdf/rdf11/",
"xsd": "http://www.w3.org/2001/XMLSchema#",
"rdfs": "http://www.w3.org/2000/01/rdf-schema#",
"mf": "http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#",
"mq": "http://www.w3.org/2001/sw/DataAccess/tests/test-query#",
"rdft": "http://www.w3.org/ns/rdftest#",
"action": {
"@id": "mf:action",
"@type": "@id"
},
"approval": {
"@id": "rdft:approval",
"@type": "@id"
},
"comment": "rdfs:comment",
"entries": {
"@id": "mf:entries",
"@container": "@list",
"@type": "@id"
},
"include": {
"@id": "mf:include",
"@container": "@list",
"@type": "@id"
},
"label": "rdfs:label",
"name": "mf:name",
"result": {
"@id": "mf:result",
"@type": "@id"
}
},
"@id": "./",
"@type": "mf:Manifest",
"label": "RDF 1.1 tests",
"comment": "\n These test suites are a product previous RDF working groups,\n and has been maintained by the\n [RDF Test Curation Community Group](https://www.w3.org/community/rdf-tests/).\n\n Community maintained at [https://github.com/w3c/rdf-tests/tree/main/rdf/rdf11](https://github.com/w3c/rdf-tests/tree/main/rdf/rdf11/).\n\n Conformance with RDF 1.1 specifications can be determined via successfully running the\n tests for relevant specifications.\n ",
"include": [
"rdf-n-triples/manifest.ttl",
"rdf-n-quads/manifest.ttl",
"rdf-mt/manifest.ttl",
"rdf-turtle/manifest.ttl",
"rdf-trig/manifest.ttl",
"rdf-xml/manifest.ttl"
],
"mf:entries": null
}
Loading