rdf-rdfxml 0.2.3 → 0.3.0
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/.yardopts +2 -0
- data/{History.txt → History.rdoc} +21 -0
- data/README.rdoc +11 -12
- data/Rakefile +11 -19
- data/VERSION +1 -1
- data/lib/rdf/rdfxml.rb +3 -2
- data/lib/rdf/rdfxml/patches/literal_hacks.rb +15 -17
- data/lib/rdf/rdfxml/reader.rb +115 -79
- data/lib/rdf/rdfxml/version.rb +4 -7
- data/lib/rdf/rdfxml/writer.rb +239 -190
- data/rdf-rdfxml.gemspec +14 -20
- data/script/parse +16 -10
- data/script/tc +10 -9
- data/spec/graph_spec.rb +0 -16
- data/spec/literal_spec.rb +2 -3
- data/spec/rdf_helper.rb +6 -6
- data/spec/reader_spec.rb +17 -17
- data/spec/spec_helper.rb +11 -4
- data/spec/writer_spec.rb +384 -331
- metadata +22 -18
- data/lib/rdf/rdfxml/patches/qname_hacks.rb +0 -57
- data/lib/rdf/rdfxml/patches/seq.rb +0 -34
- data/lib/rdf/rdfxml/patches/uri_hacks.rb +0 -24
- data/spec/uri_spec.rb +0 -115
data/rdf-rdfxml.gemspec
CHANGED
@@ -5,18 +5,17 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{rdf-rdfxml}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.3.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Gregg Kellogg"]
|
12
|
-
s.date = %q{2010-
|
13
|
-
s.description = %q{
|
14
|
-
}
|
12
|
+
s.date = %q{2010-12-27}
|
13
|
+
s.description = %q{RDF::RDFXML is an RDF/XML reader and writer for Ruby using the RDF.rb library suite.}
|
15
14
|
s.email = %q{gregg@kellogg-assoc.com}
|
16
15
|
s.extra_rdoc_files = [
|
17
16
|
"AUTHORS",
|
18
17
|
"CONTRIBUTORS",
|
19
|
-
"History.
|
18
|
+
"History.rdoc",
|
20
19
|
"README.rdoc"
|
21
20
|
]
|
22
21
|
s.files = [
|
@@ -24,7 +23,7 @@ Gem::Specification.new do |s|
|
|
24
23
|
".yardopts",
|
25
24
|
"AUTHORS",
|
26
25
|
"CONTRIBUTORS",
|
27
|
-
"History.
|
26
|
+
"History.rdoc",
|
28
27
|
"README.rdoc",
|
29
28
|
"Rakefile",
|
30
29
|
"VERSION",
|
@@ -37,9 +36,6 @@ Gem::Specification.new do |s|
|
|
37
36
|
"lib/rdf/rdfxml/patches/graph_properties.rb",
|
38
37
|
"lib/rdf/rdfxml/patches/literal_hacks.rb",
|
39
38
|
"lib/rdf/rdfxml/patches/nokogiri_hacks.rb",
|
40
|
-
"lib/rdf/rdfxml/patches/qname_hacks.rb",
|
41
|
-
"lib/rdf/rdfxml/patches/seq.rb",
|
42
|
-
"lib/rdf/rdfxml/patches/uri_hacks.rb",
|
43
39
|
"lib/rdf/rdfxml/reader.rb",
|
44
40
|
"lib/rdf/rdfxml/version.rb",
|
45
41
|
"lib/rdf/rdfxml/vocab.rb",
|
@@ -415,7 +411,6 @@ Gem::Specification.new do |s|
|
|
415
411
|
"spec/reader_spec.rb",
|
416
412
|
"spec/spec.opts",
|
417
413
|
"spec/spec_helper.rb",
|
418
|
-
"spec/uri_spec.rb",
|
419
414
|
"spec/writer_spec.rb"
|
420
415
|
]
|
421
416
|
s.homepage = %q{http://github.com/gkellogg/rdf-rdfxml}
|
@@ -431,7 +426,6 @@ Gem::Specification.new do |s|
|
|
431
426
|
"spec/rdf_helper.rb",
|
432
427
|
"spec/reader_spec.rb",
|
433
428
|
"spec/spec_helper.rb",
|
434
|
-
"spec/uri_spec.rb",
|
435
429
|
"spec/writer_spec.rb"
|
436
430
|
]
|
437
431
|
|
@@ -440,25 +434,25 @@ Gem::Specification.new do |s|
|
|
440
434
|
s.specification_version = 3
|
441
435
|
|
442
436
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
443
|
-
s.add_runtime_dependency(%q<rdf>, [">= 0.
|
437
|
+
s.add_runtime_dependency(%q<rdf>, [">= 0.3.0"])
|
444
438
|
s.add_runtime_dependency(%q<nokogiri>, [">= 1.3.3"])
|
445
|
-
s.add_development_dependency(%q<rspec>, [">= 0"])
|
446
|
-
s.add_development_dependency(%q<rdf-spec>, [">= 0
|
439
|
+
s.add_development_dependency(%q<rspec>, [">= 2.1.0"])
|
440
|
+
s.add_development_dependency(%q<rdf-spec>, [">= 0"])
|
447
441
|
s.add_development_dependency(%q<rdf-isomorphic>, [">= 0"])
|
448
442
|
s.add_development_dependency(%q<yard>, [">= 0"])
|
449
443
|
else
|
450
|
-
s.add_dependency(%q<rdf>, [">= 0.
|
444
|
+
s.add_dependency(%q<rdf>, [">= 0.3.0"])
|
451
445
|
s.add_dependency(%q<nokogiri>, [">= 1.3.3"])
|
452
|
-
s.add_dependency(%q<rspec>, [">= 0"])
|
453
|
-
s.add_dependency(%q<rdf-spec>, [">= 0
|
446
|
+
s.add_dependency(%q<rspec>, [">= 2.1.0"])
|
447
|
+
s.add_dependency(%q<rdf-spec>, [">= 0"])
|
454
448
|
s.add_dependency(%q<rdf-isomorphic>, [">= 0"])
|
455
449
|
s.add_dependency(%q<yard>, [">= 0"])
|
456
450
|
end
|
457
451
|
else
|
458
|
-
s.add_dependency(%q<rdf>, [">= 0.
|
452
|
+
s.add_dependency(%q<rdf>, [">= 0.3.0"])
|
459
453
|
s.add_dependency(%q<nokogiri>, [">= 1.3.3"])
|
460
|
-
s.add_dependency(%q<rspec>, [">= 0"])
|
461
|
-
s.add_dependency(%q<rdf-spec>, [">= 0
|
454
|
+
s.add_dependency(%q<rspec>, [">= 2.1.0"])
|
455
|
+
s.add_dependency(%q<rdf-spec>, [">= 0"])
|
462
456
|
s.add_dependency(%q<rdf-isomorphic>, [">= 0"])
|
463
457
|
s.add_dependency(%q<yard>, [">= 0"])
|
464
458
|
end
|
data/script/parse
CHANGED
@@ -1,22 +1,26 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
1
|
+
#!/usr/bin/env ruby
|
2
2
|
require 'rubygems'
|
3
3
|
$:.unshift(File.expand_path(File.join(File.dirname(__FILE__), "..", 'lib')))
|
4
4
|
require 'rdf/rdfxml'
|
5
|
+
require 'rdf/n3' rescue nil
|
5
6
|
require 'getoptlong'
|
7
|
+
require 'open-uri'
|
6
8
|
|
7
9
|
def parse(input, base)
|
8
|
-
|
9
|
-
|
10
|
+
reader_class = RDF::Reader.for($input_format.to_sym)
|
11
|
+
writer_class = RDF::Writer.for($output_format.to_sym)
|
12
|
+
raise "Reader not found for #{$input_format}" unless reader_class
|
13
|
+
raise "Writer not found for #{$output_format}" unless writer_class
|
14
|
+
puts writer_class.buffer { |writer|
|
15
|
+
reader_class.new(input, :base_uri => base, :validate => true).each do |statement|
|
10
16
|
writer << statement
|
11
17
|
end
|
12
18
|
}
|
13
19
|
end
|
14
20
|
|
15
|
-
mode = ARGV.shift
|
16
|
-
raise "Mode must be one of 'parse'" unless mode == "parse"
|
17
|
-
|
18
21
|
$verbose = false
|
19
|
-
$
|
22
|
+
$output_format = :ntriples
|
23
|
+
$input_format = :rdfxml
|
20
24
|
base_uri = "http://example.com"
|
21
25
|
input = nil
|
22
26
|
|
@@ -25,6 +29,7 @@ opts = GetoptLong.new(
|
|
25
29
|
["--verbose", GetoptLong::NO_ARGUMENT],
|
26
30
|
["--quiet", GetoptLong::NO_ARGUMENT],
|
27
31
|
["--format", GetoptLong::REQUIRED_ARGUMENT],
|
32
|
+
["--input-format", GetoptLong::REQUIRED_ARGUMENT],
|
28
33
|
["--execute", "-e", GetoptLong::REQUIRED_ARGUMENT],
|
29
34
|
["--uri", GetoptLong::REQUIRED_ARGUMENT]
|
30
35
|
)
|
@@ -32,9 +37,10 @@ opts.each do |opt, arg|
|
|
32
37
|
case opt
|
33
38
|
when '--verbose' then $verbose = true
|
34
39
|
when '--quiet' then $quiet = true
|
35
|
-
when '--debug' then
|
40
|
+
when '--debug' then ::RDF::RDFXML::debug = true
|
36
41
|
when '--execute' then input = arg
|
37
|
-
when '--format' then $
|
42
|
+
when '--format' then $output_format = arg
|
43
|
+
when '--input-format' then $input_format = arg
|
38
44
|
when '--uri' then base_uri = arg
|
39
45
|
end
|
40
46
|
end
|
@@ -44,6 +50,6 @@ if ARGV.empty?
|
|
44
50
|
parse(StringIO.new(s), base_uri)
|
45
51
|
else
|
46
52
|
ARGV.each do |test_file|
|
47
|
-
parse(
|
53
|
+
parse(Kernel.open(test_file), base_uri)
|
48
54
|
end
|
49
55
|
end
|
data/script/tc
CHANGED
@@ -2,38 +2,39 @@
|
|
2
2
|
require 'rubygems'
|
3
3
|
$:.unshift(File.expand_path(File.join(File.dirname(__FILE__), "..", 'lib')))
|
4
4
|
require 'rdf/rdfxml'
|
5
|
-
require 'spec
|
5
|
+
require File.expand_path(File.join(File.dirname(__FILE__), "..", 'spec', 'rdfa_helper'))
|
6
6
|
require 'getoptlong'
|
7
7
|
|
8
8
|
def run_tc(tc)
|
9
9
|
puts "run #{tc.name}"
|
10
|
-
puts
|
11
|
-
|
10
|
+
puts tc.input if $verbose
|
11
|
+
puts RDF::Writer.for($output_format.to_sym).buffer { |writer|
|
12
|
+
RDF::RDFXML::Reader.new(tc.input, :base_uri => tc.about, :validate => $validate).each do |statement|
|
12
13
|
writer << statement
|
13
14
|
end
|
14
15
|
}
|
15
16
|
end
|
16
17
|
|
17
18
|
$verbose = false
|
18
|
-
$
|
19
|
-
$
|
19
|
+
$output_format = :ntriples
|
20
|
+
$validate = false
|
20
21
|
suite = "rdfxml"
|
21
22
|
opts = GetoptLong.new(
|
22
23
|
["--debug", GetoptLong::NO_ARGUMENT],
|
23
24
|
["--verbose", GetoptLong::NO_ARGUMENT],
|
24
25
|
["--quiet", GetoptLong::NO_ARGUMENT],
|
25
26
|
["--suite", GetoptLong::OPTIONAL_ARGUMENT],
|
26
|
-
["--
|
27
|
+
["--validate", GetoptLong::NO_ARGUMENT],
|
27
28
|
["--format", GetoptLong::REQUIRED_ARGUMENT]
|
28
29
|
)
|
29
30
|
opts.each do |opt, arg|
|
30
31
|
case opt
|
31
32
|
when '--verbose' then $verbose = true
|
32
33
|
when '--quiet' then $quiet = true
|
33
|
-
when '--debug' then
|
34
|
-
when '--format' then $
|
34
|
+
when '--debug' then ::RDF::RDFXML::debug = true
|
35
|
+
when '--format' then $output_format = arg
|
35
36
|
when '--suite' then suite = arg
|
36
|
-
when '--
|
37
|
+
when '--validate' then $validate = true
|
37
38
|
end
|
38
39
|
end
|
39
40
|
|
data/spec/graph_spec.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
$:.unshift "."
|
2
2
|
require File.join(File.dirname(__FILE__), 'spec_helper')
|
3
3
|
require 'rdf/rdfxml/patches/graph_properties'
|
4
|
-
require 'rdf/rdfxml/patches/seq'
|
5
4
|
|
6
5
|
class EX < RDF::Vocabulary("http://example.com/"); end
|
7
6
|
|
@@ -57,19 +56,4 @@ describe RDF::Graph do
|
|
57
56
|
subject.type_of(EX.a).should == []
|
58
57
|
end
|
59
58
|
end
|
60
|
-
|
61
|
-
describe "rdf:_n sequences" do
|
62
|
-
subject {
|
63
|
-
g = RDF::Graph.new
|
64
|
-
g << [EX.Seq, RDF.type, RDF.Seq]
|
65
|
-
g << [EX.Seq, RDF._1, EX.john]
|
66
|
-
g << [EX.Seq, RDF._2, EX.jane]
|
67
|
-
g << [EX.Seq, RDF._3, EX.rick]
|
68
|
-
g
|
69
|
-
}
|
70
|
-
|
71
|
-
it "should return object list" do
|
72
|
-
subject.seq(EX.Seq).should == [EX.john, EX.jane, EX.rick]
|
73
|
-
end
|
74
|
-
end
|
75
59
|
end
|
data/spec/literal_spec.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
$:.unshift "."
|
3
3
|
require File.join(File.dirname(__FILE__), 'spec_helper')
|
4
|
-
require 'nokogiri'
|
5
4
|
|
6
5
|
describe RDF::Literal do
|
7
6
|
require 'nokogiri' rescue nil
|
@@ -73,7 +72,7 @@ describe RDF::Literal do
|
|
73
72
|
:dc => "http://purl.org/dc/terms/",
|
74
73
|
})
|
75
74
|
}
|
76
|
-
it "should add namespace" do subject.to_s.should == "<svg:svg xmlns:svg=\"http://www.w3.org/2000/svg\"></svg:svg>" end
|
75
|
+
it "should add namespace" do subject.to_s.should == "<svg:svg xmlns:svg=\"http://www.w3.org/2000/svg\" xmlns:dc=\"http://purl.org/dc/terms/\"></svg:svg>" end
|
77
76
|
end
|
78
77
|
|
79
78
|
describe "and language with an existing language embedded" do
|
@@ -91,7 +90,7 @@ describe RDF::Literal do
|
|
91
90
|
describe "with a default namespace" do
|
92
91
|
subject {
|
93
92
|
@new.call("foo <sup>bar</sup> baz!", :datatype => RDF.XMLLiteral,
|
94
|
-
:namespaces => {
|
93
|
+
:namespaces => {"" => RDF::DC.to_s})
|
95
94
|
}
|
96
95
|
|
97
96
|
it "should add namespace" do subject.to_s.should == "foo <sup xmlns=\"http://purl.org/dc/terms/\">bar</sup> baz!" end
|
data/spec/rdf_helper.rb
CHANGED
@@ -36,24 +36,24 @@ module RdfHelper
|
|
36
36
|
pred = statement.predicate.to_s.split(/[\#\/]/).last
|
37
37
|
obj = statement.object.is_a?(RDF::Literal) ? statement.object.value : statement.object.to_s
|
38
38
|
|
39
|
-
puts "#{pred}: #{obj}" if
|
39
|
+
puts "#{pred}: #{obj}" if ::RDF::RDFXML::debug?
|
40
40
|
if statement.predicate == RDF.type
|
41
41
|
self.rdf_type = obj.to_s.split(/[\#\/]/).last
|
42
42
|
#puts statement.subject.to_s
|
43
43
|
elsif pred =~ /Document\Z/i
|
44
|
-
puts "sub #{uri_prefix} in #{obj} for #{test_dir}" if
|
44
|
+
puts "sub #{uri_prefix} in #{obj} for #{test_dir}" if ::RDF::RDFXML::debug?
|
45
45
|
about = obj.dup
|
46
46
|
obj.sub!(uri_prefix, test_dir)
|
47
|
-
puts " => #{obj}" if
|
47
|
+
puts " => #{obj}" if ::RDF::RDFXML::debug?
|
48
48
|
self.send("#{pred}=", obj)
|
49
49
|
if pred == "inputDocument"
|
50
50
|
self.about ||= about
|
51
51
|
self.name ||= statement.subject.to_s.split(/[\#\/]/).last
|
52
52
|
end
|
53
53
|
elsif pred == "referenceOutput"
|
54
|
-
puts "referenceOutput: #{obj}" if
|
54
|
+
puts "referenceOutput: #{obj}" if ::RDF::RDFXML::debug?
|
55
55
|
outputDocument = obj.sub(uri_prefix, test_dir)
|
56
|
-
puts "referenceOutput: " + self.send(pred) if
|
56
|
+
puts "referenceOutput: " + self.send(pred) if ::RDF::RDFXML::debug?
|
57
57
|
elsif self.respond_to?("#{pred}=")
|
58
58
|
self.send("#{pred}=", obj)
|
59
59
|
end
|
@@ -96,7 +96,7 @@ module RdfHelper
|
|
96
96
|
return unless output
|
97
97
|
|
98
98
|
output_graph = RDF::Graph.load(self.outputDocument)
|
99
|
-
puts "result: #{CGI.escapeHTML(graph.to_ntriples)}" if
|
99
|
+
puts "result: #{CGI.escapeHTML(graph.to_ntriples)}" if ::RDF::RDFXML::debug?
|
100
100
|
graph.should Matchers::be_equivalent_graph(output_graph, self)
|
101
101
|
end
|
102
102
|
|
data/spec/reader_spec.rb
CHANGED
@@ -84,7 +84,7 @@ EOF
|
|
84
84
|
it "should recognise and create single triple for empty non-RDF root" do
|
85
85
|
sampledoc = %(<?xml version="1.0" ?>
|
86
86
|
<NotRDF />)
|
87
|
-
graph = parse(sampledoc, :base_uri => "http://example.com", :
|
87
|
+
graph = parse(sampledoc, :base_uri => "http://example.com", :validate => true)
|
88
88
|
graph.size.should == 1
|
89
89
|
statement = graph.statements.first
|
90
90
|
statement.subject.class.should == RDF::Node
|
@@ -109,7 +109,7 @@ EOF
|
|
109
109
|
</rdf:RDF>
|
110
110
|
</GenericXML>
|
111
111
|
EOF
|
112
|
-
graph = parse(sampledoc, :base_uri => "http://example.com", :
|
112
|
+
graph = parse(sampledoc, :base_uri => "http://example.com", :validate => true)
|
113
113
|
objects = graph.statements.map {|s| s.object.value}.sort
|
114
114
|
objects.should == ["Bar", "Foo"]
|
115
115
|
end
|
@@ -141,7 +141,7 @@ xmlns:ex="http://www.example.org/" xml:lang="en" xml:base="http://www.example.or
|
|
141
141
|
</rdf:RDF>
|
142
142
|
EOF
|
143
143
|
|
144
|
-
graph = parse(sampledoc, :base_uri => "http://example.com", :
|
144
|
+
graph = parse(sampledoc, :base_uri => "http://example.com", :validate => true)
|
145
145
|
#puts @debug
|
146
146
|
graph.size.should == 10
|
147
147
|
# print graph.to_ntriples
|
@@ -160,7 +160,7 @@ EOF
|
|
160
160
|
</rdf:Bag>
|
161
161
|
</rdf:RDF>
|
162
162
|
EOF
|
163
|
-
graph = parse(sampledoc, :base_uri => "http://example.com", :
|
163
|
+
graph = parse(sampledoc, :base_uri => "http://example.com", :validate => true)
|
164
164
|
graph.predicates.map(&:to_s).should include("http://www.w3.org/1999/02/22-rdf-syntax-ns#_1", "http://www.w3.org/1999/02/22-rdf-syntax-ns#_2")
|
165
165
|
end
|
166
166
|
end
|
@@ -185,7 +185,7 @@ EOF
|
|
185
185
|
EOF
|
186
186
|
|
187
187
|
lambda do
|
188
|
-
graph = parse(sampledoc, :base_uri => "http://example.com", :
|
188
|
+
graph = parse(sampledoc, :base_uri => "http://example.com", :validate => true)
|
189
189
|
end.should raise_error(RDF::ReaderError, /Obsolete attribute .*aboutEach/)
|
190
190
|
end
|
191
191
|
|
@@ -208,7 +208,7 @@ EOF
|
|
208
208
|
EOF
|
209
209
|
|
210
210
|
lambda do
|
211
|
-
graph = parse(sampledoc, :base_uri => "http://example.com", :
|
211
|
+
graph = parse(sampledoc, :base_uri => "http://example.com", :validate => true)
|
212
212
|
end.should raise_error(RDF::ReaderError, /Obsolete attribute .*aboutEachPrefix/)
|
213
213
|
end
|
214
214
|
|
@@ -221,7 +221,7 @@ EOF
|
|
221
221
|
EOF
|
222
222
|
|
223
223
|
lambda do
|
224
|
-
graph = parse(sampledoc, :base_uri => "http://example.com", :
|
224
|
+
graph = parse(sampledoc, :base_uri => "http://example.com", :validate => true)
|
225
225
|
end.should raise_error(RDF::ReaderError, /ID addtribute '.*' must be a NCName/)
|
226
226
|
end
|
227
227
|
|
@@ -237,7 +237,7 @@ EOF
|
|
237
237
|
EOF
|
238
238
|
|
239
239
|
lambda do
|
240
|
-
graph = parse(sampledoc, :base_uri => "http://example.com", :
|
240
|
+
graph = parse(sampledoc, :base_uri => "http://example.com", :validate => true)
|
241
241
|
end.should raise_error(RDF::ReaderError, /ID addtribute '.*' must be a NCName/)
|
242
242
|
end
|
243
243
|
|
@@ -251,7 +251,7 @@ EOF
|
|
251
251
|
EOF
|
252
252
|
|
253
253
|
lambda do
|
254
|
-
graph = parse(sampledoc, :base_uri => "http://example.com", :
|
254
|
+
graph = parse(sampledoc, :base_uri => "http://example.com", :validate => true)
|
255
255
|
end.should raise_error(RDF::ReaderError, "ID addtribute 'a/b' must be a NCName")
|
256
256
|
end
|
257
257
|
|
@@ -264,7 +264,7 @@ EOF
|
|
264
264
|
EOF
|
265
265
|
|
266
266
|
lambda do
|
267
|
-
graph = parse(sampledoc, :base_uri => "http://example.com", :
|
267
|
+
graph = parse(sampledoc, :base_uri => "http://example.com", :validate => true)
|
268
268
|
puts @debug
|
269
269
|
end.should raise_error(RDF::ReaderError, /Obsolete attribute .*bagID/)
|
270
270
|
end
|
@@ -291,7 +291,7 @@ EOF
|
|
291
291
|
<http://example.org/triples/#triple1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#object> \"blah\" .
|
292
292
|
EOF
|
293
293
|
|
294
|
-
graph = parse(sampledoc, :base_uri => "http://example.com", :
|
294
|
+
graph = parse(sampledoc, :base_uri => "http://example.com", :validate => true)
|
295
295
|
graph.should be_equivalent_graph(triples, :about => "http://example.com/", :trace => @debug)
|
296
296
|
end
|
297
297
|
end
|
@@ -299,7 +299,7 @@ EOF
|
|
299
299
|
context "parsing rdf files" do
|
300
300
|
def test_file(filepath, uri)
|
301
301
|
rdf_string = File.read(filepath)
|
302
|
-
graph = parse(rdf_string, :base_uri => uri, :
|
302
|
+
graph = parse(rdf_string, :base_uri => uri, :validate => true)
|
303
303
|
|
304
304
|
nt_string = File.read(filepath.sub('.rdf', '.nt'))
|
305
305
|
nt_graph = RDF::Graph.new
|
@@ -381,7 +381,7 @@ EOF
|
|
381
381
|
EOF
|
382
382
|
uri = "http://www.w3.org/2000/10/rdf-tests/rdfcore/xmlbase/Manifest.rdf#test001"
|
383
383
|
|
384
|
-
graph = parse(sampledoc, :base_uri => uri, :
|
384
|
+
graph = parse(sampledoc, :base_uri => uri, :validate => true)
|
385
385
|
graph.should be_equivalent_graph(triples, :about => uri, :trace => @debug)
|
386
386
|
end
|
387
387
|
|
@@ -398,14 +398,14 @@ EOF
|
|
398
398
|
g = RDF::Graph.new
|
399
399
|
@reader.new(rdf_string,
|
400
400
|
:base_uri => t.about,
|
401
|
-
:
|
401
|
+
:validate => false,
|
402
402
|
:debug => t.debug).each do |statement|
|
403
403
|
g << statement
|
404
404
|
end
|
405
405
|
g
|
406
406
|
end
|
407
|
-
rescue
|
408
|
-
if t.inputDocument =~ %r(
|
407
|
+
rescue RSpec::Expectations::ExpectationNotMetError => e
|
408
|
+
if t.inputDocument =~ %r(xml-literal|xml-canon)
|
409
409
|
pending("XMLLiteral canonicalization not implemented yet")
|
410
410
|
else
|
411
411
|
raise
|
@@ -426,7 +426,7 @@ EOF
|
|
426
426
|
g = RDF::Graph.new
|
427
427
|
@reader.new(rdf_string,
|
428
428
|
:base_uri => t.about,
|
429
|
-
:
|
429
|
+
:validate => true).each do |statement|
|
430
430
|
g << statement
|
431
431
|
end
|
432
432
|
g.should be_empty
|
data/spec/spec_helper.rb
CHANGED
@@ -3,12 +3,13 @@ $:.unshift(File.join(File.dirname(__FILE__), '..', '..', 'rdf-n3', 'lib'))
|
|
3
3
|
$:.unshift File.dirname(__FILE__)
|
4
4
|
|
5
5
|
require 'rubygems'
|
6
|
-
require '
|
6
|
+
require 'rspec'
|
7
7
|
require 'matchers'
|
8
8
|
require 'bigdecimal' # XXX Remove Me
|
9
9
|
require 'rdf/rdfxml'
|
10
10
|
require 'rdf/ntriples'
|
11
11
|
require 'rdf/spec'
|
12
|
+
require 'rdf/spec/matchers'
|
12
13
|
require 'rdf/isomorphic'
|
13
14
|
|
14
15
|
include Matchers
|
@@ -28,8 +29,14 @@ module RDF
|
|
28
29
|
end
|
29
30
|
end
|
30
31
|
|
31
|
-
|
32
|
-
|
32
|
+
::RSpec.configure do |c|
|
33
|
+
c.filter_run :focus => true
|
34
|
+
c.run_all_when_everything_filtered = true
|
35
|
+
c.exclusion_filter = {
|
36
|
+
:ruby => lambda { |version| !(RUBY_VERSION.to_s =~ /^#{version.to_s}/) },
|
37
|
+
}
|
38
|
+
c.include(Matchers)
|
39
|
+
c.include(RDF::Spec::Matchers)
|
33
40
|
end
|
34
41
|
|
35
42
|
# Heuristically detect the input stream
|
@@ -45,7 +52,7 @@ def detect_format(stream)
|
|
45
52
|
case string
|
46
53
|
when /<\w+:RDF/ then RDF::RDFXML::Reader
|
47
54
|
when /<RDF/ then RDF::RDFXML::Reader
|
48
|
-
when /<html/i then RDF::RDFa::Reader
|
55
|
+
#when /<html/i then RDF::RDFa::Reader
|
49
56
|
when /@prefix/i then RDF::N3::Reader
|
50
57
|
else RDF::NTriples::Reader
|
51
58
|
end
|