rdf_context 0.5.9.1 → 0.5.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +0 -1
- data/History.rdoc +23 -2
- data/Rakefile +17 -17
- data/VERSION +1 -1
- data/bin/rdf_context +1 -4
- data/lib/rdf_context.rb +55 -19
- data/lib/rdf_context/aggregate_graph.rb +0 -2
- data/lib/rdf_context/bnode.rb +14 -1
- data/lib/rdf_context/conjunctive_graph.rb +0 -2
- data/lib/rdf_context/graph.rb +9 -10
- data/lib/rdf_context/literal.rb +39 -56
- data/lib/rdf_context/n3_grammar.treetop +2 -2
- data/lib/rdf_context/n3parser.rb +7 -5
- data/lib/rdf_context/parser.rb +2 -3
- data/lib/rdf_context/quoted_graph.rb +0 -2
- data/lib/rdf_context/rdfaparser.rb +93 -68
- data/lib/rdf_context/rdfxmlparser.rb +1 -1
- data/lib/rdf_context/resource.rb +56 -0
- data/lib/rdf_context/serializer/abstract_serializer.rb +0 -2
- data/lib/rdf_context/serializer/nt_serializer.rb +0 -2
- data/lib/rdf_context/serializer/recursive_serializer.rb +0 -4
- data/lib/rdf_context/serializer/turtle_serializer.rb +0 -2
- data/lib/rdf_context/serializer/xml_serializer.rb +0 -2
- data/lib/rdf_context/store/abstract_sql_store.rb +3 -1
- data/lib/rdf_context/store/active_record_store.rb +272 -0
- data/lib/rdf_context/store/list_store.rb +2 -2
- data/lib/rdf_context/store/memory_store.rb +2 -2
- data/lib/rdf_context/store/sqlite3_store.rb +112 -48
- data/lib/rdf_context/term_utils.rb +0 -4
- data/lib/rdf_context/triple.rb +1 -3
- data/lib/rdf_context/uriref.rb +14 -1
- data/rdf_context.gemspec +872 -0
- data/script/tc +4 -4
- data/spec/active_record_store_spec.rb +61 -0
- data/spec/aggregate_graph_spec.rb +1 -1
- data/spec/bnode_spec.rb +37 -1
- data/spec/conjunctive_graph_spec.rb +1 -1
- data/spec/cwm_spec.rb +5 -5
- data/spec/duration_spec.rb +1 -1
- data/spec/graph_spec.rb +16 -2
- data/spec/list_store_spec.rb +1 -1
- data/spec/literal_spec.rb +47 -14
- data/spec/memory_store_spec.rb +1 -1
- data/spec/n3parser_spec.rb +19 -5
- data/spec/namespaces_spec.rb +1 -1
- data/spec/parser_spec.rb +1 -1
- data/spec/rdf_helper.rb +18 -15
- data/spec/rdfa_helper.rb +27 -14
- data/spec/rdfa_parser_spec.rb +28 -9
- data/spec/rdfxml_spec.rb +3 -3
- data/spec/spec_helper.rb +10 -5
- data/spec/sqlite3_store_spec.rb +1 -1
- data/spec/string_hacks_spec.rb +2 -1
- data/spec/swap_spec.rb +7 -7
- data/spec/swap_test/ref/contexts-1.n3 +12 -0
- data/spec/swap_test/ref/prefix2.rdf +33 -0
- data/spec/swap_test/ref/xmllit.nt +1 -1
- data/spec/swap_test/regression.n3 +18 -18
- data/spec/triple_spec.rb +1 -1
- data/spec/turtle_serializer_spec.rb +3 -3
- data/spec/turtle_spec.rb +3 -3
- data/spec/uriref_spec.rb +31 -1
- metadata +13 -15
data/script/tc
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
1
|
+
#!/usr/bin/env ruby
|
2
2
|
require 'rubygems'
|
3
3
|
$:.unshift(File.join(File.expand_path(File.dirname(__FILE__)), "..", 'lib'))
|
4
4
|
require 'rdf_context'
|
5
|
-
require
|
5
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), "..", "spec", "rdfa_helper")
|
6
6
|
require 'getoptlong'
|
7
7
|
|
8
8
|
def run_tc(tc)
|
@@ -48,9 +48,9 @@ test_cases = RdfaHelper::TestCase.test_cases(suite)
|
|
48
48
|
|
49
49
|
::RdfContext::debug = debug
|
50
50
|
|
51
|
-
puts test_cases.length
|
51
|
+
puts "#{suite}: #{test_cases.length} test cases"
|
52
52
|
|
53
|
-
test_cases
|
53
|
+
test_cases.each do |tc|
|
54
54
|
next unless ARGV.empty? || ARGV.any? {|n| tc.name.match(/#{n}/)}
|
55
55
|
run_tc(tc)
|
56
56
|
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
$:.unshift "."
|
2
|
+
require File.join(File.dirname(__FILE__), 'spec_helper')
|
3
|
+
require File.join(File.dirname(__FILE__), 'store_helper')
|
4
|
+
|
5
|
+
describe ActiveRecordStore do
|
6
|
+
before(:all) do
|
7
|
+
FileUtils.rm_rf(TMP_DIR)
|
8
|
+
Dir.mkdir(TMP_DIR)
|
9
|
+
@dbfile = File.join(TMP_DIR, "sqlite3.db")
|
10
|
+
@identifier = URIRef.new("http://identifier")
|
11
|
+
end
|
12
|
+
|
13
|
+
before(:each) do
|
14
|
+
ActiveRecord::Base.establish_connection(
|
15
|
+
:adapter => 'sqlite3',
|
16
|
+
:database => @dbfile)
|
17
|
+
#::RdfContext::debug =true
|
18
|
+
@store = ActiveRecordStore.new(@identifier)
|
19
|
+
@store.setup
|
20
|
+
end
|
21
|
+
|
22
|
+
after(:all) do
|
23
|
+
FileUtils.rm_rf(TMP_DIR)
|
24
|
+
end
|
25
|
+
|
26
|
+
after(:each) do
|
27
|
+
FileUtils.rm(@dbfile) if File.file?(@dbfile)
|
28
|
+
end
|
29
|
+
|
30
|
+
subject { @store }
|
31
|
+
it_should_behave_like "Store"
|
32
|
+
it_should_behave_like "Context Aware Store"
|
33
|
+
|
34
|
+
it "should close db" do
|
35
|
+
subject.close
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should find contexts with type" do
|
39
|
+
triple = Triple.new("http://foo", RDF_TYPE, "http://baz")
|
40
|
+
subject.add(triple, nil)
|
41
|
+
subject.contexts(triple).length.should == 1
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should find triples with typed literal" do
|
45
|
+
triple = Triple.new("http://foo", RDF_TYPE, Literal.build_from(1.1))
|
46
|
+
subject.add(triple, nil)
|
47
|
+
subject.contexts(triple).length.should == 1
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should find triples with untyped literal and lang" do
|
51
|
+
triple = Triple.new("http://foo", RDF_TYPE, Literal.untyped("foo", "en-US"))
|
52
|
+
subject.add(triple, nil)
|
53
|
+
subject.contexts(triple).length.should == 1
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should find contexts pattern triple" do
|
57
|
+
triple = Triple.new("http://foo", RDF_TYPE, "http://baz")
|
58
|
+
subject.add(triple, nil)
|
59
|
+
subject.contexts(Triple.new(nil, nil, nil)).length.should == 1
|
60
|
+
end
|
61
|
+
end
|
data/spec/bnode_spec.rb
CHANGED
@@ -1,8 +1,44 @@
|
|
1
1
|
$:.unshift "."
|
2
2
|
require File.join(File.dirname(__FILE__), 'spec_helper')
|
3
|
-
describe
|
3
|
+
describe BNode do
|
4
4
|
before(:all) { @context = {} }
|
5
5
|
|
6
|
+
describe "descriminators" do
|
7
|
+
subject { BNode.new }
|
8
|
+
|
9
|
+
it "returns true for bnode?" do
|
10
|
+
subject.should be_bnode
|
11
|
+
end
|
12
|
+
it "returns false for graph?" do
|
13
|
+
subject.should_not be_graph
|
14
|
+
end
|
15
|
+
it "returns false for literal?" do
|
16
|
+
subject.should_not be_literal
|
17
|
+
end
|
18
|
+
it "returns false for uri?" do
|
19
|
+
subject.should_not be_uri
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe ".parse" do
|
24
|
+
subject {BNode.parse("_:bn1292025322717a")}
|
25
|
+
it "returns nil if unrecognized pattern" do
|
26
|
+
BNode.parse("foo").should be_nil
|
27
|
+
end
|
28
|
+
|
29
|
+
it "returns a BNode" do
|
30
|
+
subject.should be_a(BNode)
|
31
|
+
end
|
32
|
+
|
33
|
+
it "returns node with same identifier" do
|
34
|
+
subject.identifier.should == "bn1292025322717a"
|
35
|
+
end
|
36
|
+
|
37
|
+
it "returns node with different identifier if not native" do
|
38
|
+
BNode.parse("_:a").identifier.should_not == "a"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
6
42
|
describe "which have custom identifiers" do
|
7
43
|
subject { BNode.new("foo", @context) }
|
8
44
|
|
data/spec/cwm_spec.rb
CHANGED
@@ -2,7 +2,7 @@ $:.unshift "."
|
|
2
2
|
require File.join(File.dirname(__FILE__), 'spec_helper')
|
3
3
|
include RdfContext
|
4
4
|
|
5
|
-
describe
|
5
|
+
describe N3Parser do
|
6
6
|
describe "w3c cwm tests" do
|
7
7
|
require 'rdf_helper'
|
8
8
|
|
@@ -12,19 +12,19 @@ describe "N3 parser" do
|
|
12
12
|
|
13
13
|
# Negative parser tests should raise errors.
|
14
14
|
test_cases.each do |t|
|
15
|
-
#next unless t.about
|
15
|
+
#next unless t.about =~ /rdfms-rdf-names-use/
|
16
16
|
#next unless t.name =~ /11/
|
17
17
|
#puts t.inspect
|
18
18
|
specify "test #{t.name}: " + (t.description || "#{t.inputDocument} against #{t.outputDocument}") do
|
19
19
|
begin
|
20
20
|
t.run_test do |rdf_string, parser|
|
21
|
-
parser.parse(rdf_string, t.about
|
21
|
+
parser.parse(rdf_string, t.about, :strict => true, :debug => [])
|
22
22
|
end
|
23
|
-
rescue
|
23
|
+
rescue RSpec::Expectations::ExpectationNotMetError => e
|
24
24
|
if t.status == "pending"
|
25
25
|
pending("Formulae not supported") { raise }
|
26
26
|
else
|
27
|
-
|
27
|
+
pending("CWM tests not conformant")
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
data/spec/duration_spec.rb
CHANGED
data/spec/graph_spec.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
$:.unshift "."
|
2
2
|
require File.join(File.dirname(__FILE__), 'spec_helper')
|
3
3
|
|
4
|
-
describe
|
4
|
+
describe Graph do
|
5
5
|
before(:all) do
|
6
6
|
@ex = Namespace.new("http://example.org/", "ex")
|
7
7
|
@foaf = Namespace.new("http://xmlns.com/foaf/0.1/", "foaf")
|
@@ -83,6 +83,21 @@ describe "Graphs" do
|
|
83
83
|
subject.frozen?.should be_true
|
84
84
|
end
|
85
85
|
|
86
|
+
describe "descriminators" do
|
87
|
+
it "returns false for bnode?" do
|
88
|
+
subject.should_not be_bnode
|
89
|
+
end
|
90
|
+
it "returns true for graph?" do
|
91
|
+
subject.should be_graph
|
92
|
+
end
|
93
|
+
it "returns false for literal?" do
|
94
|
+
subject.should_not be_literal
|
95
|
+
end
|
96
|
+
it "returns false for uri?" do
|
97
|
+
subject.should_not be_uri
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
86
101
|
describe "with identifier" do
|
87
102
|
before(:all) { @identifier = URIRef.new("http://foo.bar") }
|
88
103
|
subject { Graph.new(:identifier => @identifier) }
|
@@ -474,7 +489,6 @@ HERE
|
|
474
489
|
g = Graph.new(:store => ListStore.new)
|
475
490
|
g.add_seq(@ex.List, @ex.includes, [@ex.john, @ex.jane, @ex.rick])
|
476
491
|
g.add_seq(@ex.List, @ex.includes, [@ex.john, @ex.jane, @ex.rick, @ex.julie])
|
477
|
-
puts g.properties(@ex.List).inspect
|
478
492
|
l = g.properties(@ex.List)[@ex.includes.to_s].first
|
479
493
|
l.should be_a(BNode)
|
480
494
|
g.seq(l).should == [@ex.john, @ex.jane, @ex.rick, @ex.julie]
|
data/spec/list_store_spec.rb
CHANGED
data/spec/literal_spec.rb
CHANGED
@@ -2,7 +2,40 @@
|
|
2
2
|
$:.unshift "."
|
3
3
|
require File.join(File.dirname(__FILE__), 'spec_helper')
|
4
4
|
|
5
|
-
describe
|
5
|
+
describe Literal do
|
6
|
+
describe "descriminators" do
|
7
|
+
subject { Literal.untyped("gregg") }
|
8
|
+
|
9
|
+
it "returns false for bnode?" do
|
10
|
+
subject.should_not be_bnode
|
11
|
+
end
|
12
|
+
it "returns false for graph?" do
|
13
|
+
subject.should_not be_graph
|
14
|
+
end
|
15
|
+
it "returns true for literal?" do
|
16
|
+
subject.should be_literal
|
17
|
+
end
|
18
|
+
it "returns false for uri?" do
|
19
|
+
subject.should_not be_uri
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe ".parse" do
|
24
|
+
it "returns nil for unencoded string" do
|
25
|
+
Literal.parse("gregg").should be_nil
|
26
|
+
end
|
27
|
+
|
28
|
+
{
|
29
|
+
%q("gregg") => Literal.untyped("gregg"),
|
30
|
+
%q("gregg"@en) => Literal.untyped("gregg", "en"),
|
31
|
+
%q("gregg"^^<http://www.w3.org/2001/XMLSchema#string>) => Literal.typed("gregg", XSD_NS.string),
|
32
|
+
}.each_pair do |str, lit|
|
33
|
+
it "parses '#{str}'" do
|
34
|
+
Literal.parse(str).should == lit
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
6
39
|
describe "an untyped string" do
|
7
40
|
subject {Literal.untyped("tom")}
|
8
41
|
it "should be equal if they have the same contents" do should == Literal.untyped("tom") end
|
@@ -270,28 +303,28 @@ describe "Literals: " do
|
|
270
303
|
describe "with a namespace" do
|
271
304
|
subject {
|
272
305
|
Literal.typed("foo <sup>bar</sup> baz!", "http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral",
|
273
|
-
:namespaces => {"dc" =>
|
306
|
+
:namespaces => {"dc" => "http://purl.org/dc/terms/"})
|
274
307
|
}
|
275
308
|
|
276
309
|
describe "encodings" do
|
277
|
-
it "should return n3" do subject.to_n3.should == "\"foo <sup>bar</sup> baz!\"^^<http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral>" end
|
310
|
+
it "should return n3" do subject.to_n3.should == "\"foo <sup xmlns:dc=\\\"http://purl.org/dc/terms/\\\">bar</sup> baz!\"^^<http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral>" end
|
278
311
|
it "should return ntriples" do subject.to_ntriples.should == subject.to_n3 end
|
279
|
-
it "should return xml_args" do subject.xml_args.should == ["foo <sup>bar</sup> baz!", {"rdf:parseType" => "Literal"}] end
|
280
|
-
it "should return TriX" do subject.to_trix.should == "<typedLiteral datatype=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral\">foo <sup>bar</sup> baz!</typedLiteral>" end
|
312
|
+
it "should return xml_args" do subject.xml_args.should == ["foo <sup xmlns:dc=\"http://purl.org/dc/terms/\">bar</sup> baz!", {"rdf:parseType" => "Literal"}] end
|
313
|
+
it "should return TriX" do subject.to_trix.should == "<typedLiteral datatype=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral\">foo <sup xmlns:dc=\"http://purl.org/dc/terms/\">bar</sup> baz!</typedLiteral>" end
|
281
314
|
end
|
282
315
|
|
283
316
|
describe "and language" do
|
284
317
|
subject {
|
285
318
|
Literal.typed("foo <sup>bar</sup> baz!", "http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral",
|
286
|
-
:namespaces => {"dc" =>
|
319
|
+
:namespaces => {"dc" => "http://purl.org/dc/terms/"},
|
287
320
|
:language => "fr")
|
288
321
|
}
|
289
322
|
|
290
323
|
describe "encodings" do
|
291
|
-
it "should return n3" do subject.to_n3.should == "\"foo <sup xml:lang=\\\"fr\\\">bar</sup> baz!\"\^^<http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral>" end
|
324
|
+
it "should return n3" do subject.to_n3.should == "\"foo <sup xmlns:dc=\\\"http://purl.org/dc/terms/\\\" xml:lang=\\\"fr\\\">bar</sup> baz!\"\^^<http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral>" end
|
292
325
|
it "should return ntriples" do subject.to_ntriples.should == subject.to_n3 end
|
293
|
-
it "should return xml_args" do subject.xml_args.should == ["foo <sup xml:lang=\"fr\">bar</sup> baz!", {"rdf:parseType" => "Literal"}] end
|
294
|
-
it "should return TriX" do subject.to_trix.should == "<typedLiteral datatype=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral\">foo <sup xml:lang=\"fr\">bar</sup> baz!</typedLiteral>" end
|
326
|
+
it "should return xml_args" do subject.xml_args.should == ["foo <sup xmlns:dc=\"http://purl.org/dc/terms/\" xml:lang=\"fr\">bar</sup> baz!", {"rdf:parseType" => "Literal"}] end
|
327
|
+
it "should return TriX" do subject.to_trix.should == "<typedLiteral datatype=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral\">foo <sup xmlns:dc=\"http://purl.org/dc/terms/\" xml:lang=\"fr\">bar</sup> baz!</typedLiteral>" end
|
295
328
|
end
|
296
329
|
end
|
297
330
|
|
@@ -334,18 +367,18 @@ describe "Literals: " do
|
|
334
367
|
Literal.typed(content,
|
335
368
|
"http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral",
|
336
369
|
:namespaces => {
|
337
|
-
"svg" =>
|
338
|
-
"dc" =>
|
370
|
+
"svg" => "http://www.w3.org/2000/svg",
|
371
|
+
"dc" => "http://purl.org/dc/terms/"
|
339
372
|
})
|
340
373
|
}
|
341
|
-
it "should return xml_args" do subject.xml_args.should == ["<svg:svg xmlns:svg=\"http://www.w3.org/2000/svg\"></svg:svg>", {"rdf:parseType" => "Literal"}] end
|
374
|
+
it "should return xml_args" do subject.xml_args.should == ["<svg:svg xmlns:svg=\"http://www.w3.org/2000/svg\" xmlns:dc=\"http://purl.org/dc/terms/\"></svg:svg>", {"rdf:parseType" => "Literal"}] end
|
342
375
|
end
|
343
376
|
|
344
377
|
describe "and existing namespace definition" do
|
345
378
|
subject {
|
346
379
|
Literal.typed("<svg:svg xmlns:svg=\"http://www.w3.org/2000/svg\"/>",
|
347
380
|
"http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral",
|
348
|
-
:namespaces => {"svg" =>
|
381
|
+
:namespaces => {"svg" => "http://www.w3.org/2000/svg"})
|
349
382
|
}
|
350
383
|
it "should return xml_args" do subject.xml_args.should == ["<svg:svg xmlns:svg=\"http://www.w3.org/2000/svg\"></svg:svg>", {"rdf:parseType" => "Literal"}] end
|
351
384
|
end
|
@@ -354,7 +387,7 @@ describe "Literals: " do
|
|
354
387
|
describe "with a default namespace" do
|
355
388
|
subject {
|
356
389
|
Literal.typed("foo <sup>bar</sup> baz!", "http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral",
|
357
|
-
:namespaces => {"" =>
|
390
|
+
:namespaces => {"" => "http://purl.org/dc/terms/"})
|
358
391
|
}
|
359
392
|
|
360
393
|
describe "encodings" do
|
data/spec/memory_store_spec.rb
CHANGED
data/spec/n3parser_spec.rb
CHANGED
@@ -3,7 +3,7 @@ $:.unshift "."
|
|
3
3
|
require File.join(File.dirname(__FILE__), 'spec_helper')
|
4
4
|
include RdfContext
|
5
5
|
|
6
|
-
describe
|
6
|
+
describe N3Parser do
|
7
7
|
before(:each) { @parser = N3Parser.new(:strict => true) }
|
8
8
|
|
9
9
|
describe "with simple ntriples" do
|
@@ -170,6 +170,12 @@ describe "N3 parser" do
|
|
170
170
|
end
|
171
171
|
end
|
172
172
|
|
173
|
+
it "should allow mixed-case language" do
|
174
|
+
n3doc = %(@prefix : <http://example/> . :a :p "xyz"@EN .)
|
175
|
+
statement = @parser.parse(n3doc).triples.first
|
176
|
+
statement.object.to_ntriples.should == %("xyz"@en)
|
177
|
+
end
|
178
|
+
|
173
179
|
it "should create typed literals" do
|
174
180
|
n3doc = "<http://example.org/joe> <http://xmlns.com/foaf/0.1/name> \"Joe\"^^<http://www.w3.org/2001/XMLSchema#string> ."
|
175
181
|
@parser.parse(n3doc)
|
@@ -372,9 +378,13 @@ describe "N3 parser" do
|
|
372
378
|
@parser.parse(n3, "http://a/b").should be_equivalent_graph(nt, :about => "http://a/b", :trace => @parser.debug, :compare => :array)
|
373
379
|
end
|
374
380
|
|
375
|
-
it "should do something for @forAll"
|
381
|
+
it "should do something for @forAll" do
|
382
|
+
pending
|
383
|
+
end
|
376
384
|
|
377
|
-
it "should do something for @forSome"
|
385
|
+
it "should do something for @forSome" do
|
386
|
+
pending
|
387
|
+
end
|
378
388
|
end
|
379
389
|
|
380
390
|
describe "namespaces" do
|
@@ -706,9 +716,13 @@ describe "N3 parser" do
|
|
706
716
|
end
|
707
717
|
|
708
718
|
describe "formulae" do
|
709
|
-
it "should require that graph be formula_aware when encountering a formlua"
|
719
|
+
it "should require that graph be formula_aware when encountering a formlua" do
|
720
|
+
pending
|
721
|
+
end
|
710
722
|
|
711
|
-
it "should separate triples between specified and quoted graphs"
|
723
|
+
it "should separate triples between specified and quoted graphs" do
|
724
|
+
pending
|
725
|
+
end
|
712
726
|
end
|
713
727
|
|
714
728
|
describe "object lists" do
|
data/spec/namespaces_spec.rb
CHANGED
data/spec/parser_spec.rb
CHANGED
data/spec/rdf_helper.rb
CHANGED
@@ -51,37 +51,40 @@ module RdfHelper
|
|
51
51
|
def parse_w3c(triples, uri_prefix, test_dir)
|
52
52
|
triples.each do |statement|
|
53
53
|
next if statement.subject.is_a?(BNode)
|
54
|
-
|
54
|
+
pred = statement.predicate.to_s.split(/[\#\/]/).last
|
55
|
+
obj = statement.object.to_s
|
56
|
+
|
57
|
+
puts "#{pred.inspect}: #{obj}" if ::RdfContext::debug?
|
58
|
+
pred = "outputDocument" if pred == "referenceOutput"
|
55
59
|
if statement.is_type?
|
56
60
|
self.rdf_type = statement.object.short_name
|
57
|
-
elsif
|
58
|
-
puts "#{
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
61
|
+
elsif pred =~ /Document\Z/i
|
62
|
+
puts "sub #{uri_prefix} in #{obj} for #{test_dir}" if ::RdfContext::debug?
|
63
|
+
about = obj
|
64
|
+
obj = obj.sub(uri_prefix, test_dir)
|
65
|
+
puts " => #{obj}" if ::RdfContext::debug?
|
66
|
+
self.send("#{pred}=", obj)
|
67
|
+
if pred == "inputDocument"
|
68
|
+
self.about ||= about
|
69
|
+
self.name ||= statement.subject.to_s.split(/[\#\/]/).last
|
64
70
|
end
|
65
|
-
elsif statement.predicate.short_name == "referenceOutput"
|
66
|
-
puts "referenceOutput: #{statement.object.inspect}" if ::RdfContext::debug?
|
67
|
-
outputDocument = statement.object.to_s.sub(uri_prefix, test_dir)
|
68
|
-
puts "referenceOutput: " + self.send("#{statement.predicate.short_name}") if ::RdfContext::debug?
|
69
71
|
elsif self.respond_to?("#{statement.predicate.short_name}=")
|
70
|
-
self.send("#{
|
72
|
+
self.send("#{pred}=", obj)
|
71
73
|
end
|
72
74
|
end
|
73
75
|
end
|
74
76
|
|
75
77
|
def parse_mf(subject, uri_prefix, test_dir, graph)
|
76
78
|
props = graph.properties(subject)
|
79
|
+
puts "MF #{subject}: #{props.inspect}" if ::RdfContext::debug?
|
77
80
|
@name = (props[MF_NS.name.to_s] || []).first.to_s
|
78
81
|
@description = (props[RDFS_NS.comment.to_s] || []).first.to_s
|
79
82
|
@outputDocument = (props[MF_NS.result.to_s] || []).first
|
80
83
|
@outputDocument = @outputDocument.to_s.sub(uri_prefix, test_dir) if @outputDocument
|
81
84
|
action = (props[MF_NS.action.to_s] || []).first
|
82
85
|
a_props = graph.properties(action)
|
83
|
-
@about = (a_props[QT_NS.data.to_s] || []).first
|
84
|
-
@inputDocument = @about.
|
86
|
+
@about = (a_props[QT_NS.data.to_s] || []).first.to_s
|
87
|
+
@inputDocument = @about.sub(uri_prefix, test_dir)
|
85
88
|
end
|
86
89
|
|
87
90
|
def inspect
|