rdf-n3 0.0.3 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +3 -0
- data/Rakefile +3 -3
- data/VERSION +1 -1
- data/lib/rdf/n3/patches/literal_normalization.rb +126 -99
- data/lib/rdf/n3/reader.rb +10 -9
- data/lib/rdf/n3/version.rb +2 -2
- data/lib/rdf/n3/writer.rb +1 -1
- data/lib/rdf/n3.rb +0 -2
- data/rdf-n3.gemspec +13 -17
- data/spec/literal_spec.rb +22 -343
- data/spec/n3reader_spec.rb +19 -19
- data/spec/spec_helper.rb +1 -0
- metadata +12 -33
- data/lib/rdf/n3/patches/literal_hacks.rb +0 -23
- data/lib/rdf/n3/patches/rdf_escape.rb +0 -131
- data/spec/turtle_serializer_spec.rb +0 -226
data/spec/literal_spec.rb
CHANGED
@@ -1,382 +1,61 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
require File.join(File.dirname(__FILE__), 'spec_helper')
|
3
|
-
require 'date'
|
4
|
-
require 'time'
|
5
3
|
require 'nokogiri'
|
6
4
|
|
7
5
|
describe RDF::Literal do
|
8
|
-
|
9
|
-
subject {RDF::Literal.new("gregg")}
|
10
|
-
it "should be equal if they have the same contents" do should == RDF::Literal.new("gregg") end
|
11
|
-
it "should not be equal if they do not have the same contents" do should_not == RDF::Literal.new("tim") end
|
12
|
-
it "should match a string" do should == "gregg" end
|
13
|
-
it "should return a string using to_s" do subject.to_s.should == %("gregg") end
|
14
|
-
|
15
|
-
describe "should handle specific cases" do
|
16
|
-
{
|
17
|
-
'"Gregg"' => RDF::Literal.new("Gregg"),
|
18
|
-
'"\u677E\u672C \u540E\u5B50"' => RDF::Literal.new("松本 后子"),
|
19
|
-
'"D\u00FCrst"' => RDF::Literal.new("Dürst"),
|
20
|
-
}.each_pair do |encoded, literal|
|
21
|
-
it "should encode '#{literal.value}'" do
|
22
|
-
literal.to_s.should == encoded
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
# Ruby 1.9 only
|
27
|
-
{
|
28
|
-
'"\U00015678another"' => RDF::Literal.new("\u{15678}another"),
|
29
|
-
}.each_pair do |encoded, literal|
|
30
|
-
it "should encode '#{literal.value}'" do
|
31
|
-
literal.to_s.should == encoded
|
32
|
-
end
|
33
|
-
end if defined?(::Encoding)
|
34
|
-
end
|
35
|
-
|
36
|
-
describe "encodings" do
|
37
|
-
it "should return n3" do subject.to_s.should == "\"gregg\"" end
|
38
|
-
end
|
39
|
-
|
40
|
-
describe "with extended characters" do
|
41
|
-
subject { RDF::Literal.new("松本 后子") }
|
42
|
-
|
43
|
-
describe "encodings" do
|
44
|
-
it "should return n3" do subject.to_s.should == '"\u677E\u672C \u540E\u5B50"' end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
describe "with a language" do
|
49
|
-
subject { RDF::Literal.new("gregg", :language => "en") }
|
50
|
-
|
51
|
-
it "should accept a language tag" do
|
52
|
-
subject.language.should == :en
|
53
|
-
end
|
54
|
-
|
55
|
-
it "should be equal if they have the same contents and language" do
|
56
|
-
should == RDF::Literal.new("gregg", :language => "en")
|
57
|
-
end
|
58
|
-
|
59
|
-
it "should not be equal if they do not have the same contents" do
|
60
|
-
should_not == RDF::Literal.new("tim", :language => "en")
|
61
|
-
end
|
62
|
-
|
63
|
-
it "should not be equal if they do not have the same language" do
|
64
|
-
should_not == RDF::Literal.new("gregg", :language => "fr")
|
65
|
-
end
|
6
|
+
require 'nokogiri' rescue nil
|
66
7
|
|
67
|
-
|
68
|
-
|
69
|
-
end
|
70
|
-
|
71
|
-
it "should normalize language tags to lower case" do
|
72
|
-
f = RDF::Literal.new("gregg", :language => "EN")
|
73
|
-
f.language.should == :en
|
74
|
-
end
|
75
|
-
end
|
8
|
+
before :each do
|
9
|
+
@new = Proc.new { |*args| RDF::Literal.new(*args) }
|
76
10
|
end
|
77
|
-
|
78
|
-
describe "a typed string" do
|
79
|
-
subject { RDF::Literal.new("gregg", :datatype => RDF::XSD.string) }
|
80
|
-
|
81
|
-
it "accepts an encoding" do
|
82
|
-
subject.datatype.to_s.should == RDF::XSD.string.to_s
|
83
|
-
end
|
84
|
-
|
85
|
-
it "should be equal if they have the same contents and datatype" do
|
86
|
-
should == RDF::Literal.new("gregg", :datatype => RDF::XSD.string)
|
87
|
-
end
|
88
|
-
|
89
|
-
it "should not be equal if they do not have the same contents" do
|
90
|
-
should_not == RDF::Literal.new("tim", :datatype => RDF::XSD.string)
|
91
|
-
end
|
92
11
|
|
93
|
-
it "should not be equal if they do not have the same datatype" do
|
94
|
-
should_not == RDF::Literal.new("gregg", :datatype => RDF::XSD.token)
|
95
|
-
end
|
96
|
-
|
97
|
-
describe "encodings" do
|
98
|
-
it "should return n3" do subject.to_s.should == "\"gregg\"^^<http://www.w3.org/2001/XMLSchema#string>" end
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
describe "a boolean" do
|
103
|
-
subject { RDF::Literal.new(true, :datatype => RDF::XSD.boolean) }
|
104
|
-
describe "encodings" do
|
105
|
-
it "should return n3" do subject.to_s.should == "\"true\"^^<http://www.w3.org/2001/XMLSchema#boolean>" end
|
106
|
-
end
|
107
|
-
|
108
|
-
it "should infer type" do
|
109
|
-
int = RDF::Literal.new(true)
|
110
|
-
int.datatype.should == RDF::XSD.boolean
|
111
|
-
end
|
112
|
-
|
113
|
-
it "should have string contents" do subject.value.should == "true" end
|
114
|
-
it "should have native contents" do subject.object.should == true end
|
115
|
-
end
|
116
|
-
|
117
|
-
describe "an integer" do
|
118
|
-
subject { RDF::Literal.new(5, :datatype => RDF::XSD.int) }
|
119
|
-
describe "encodings" do
|
120
|
-
it "should return n3" do subject.to_s.should == "\"5\"^^<http://www.w3.org/2001/XMLSchema#int>" end
|
121
|
-
end
|
122
|
-
|
123
|
-
it "should infer type" do
|
124
|
-
int = RDF::Literal.new(15)
|
125
|
-
int.datatype.should == RDF::XSD.integer
|
126
|
-
end
|
127
|
-
|
128
|
-
it "should have string contents" do subject.value.should == "5" end
|
129
|
-
it "should have native contents" do subject.object.should == 5 end
|
130
|
-
end
|
131
|
-
|
132
|
-
describe "a float" do
|
133
|
-
subject { RDF::Literal.new(15.4, :datatype => RDF::XSD.float) }
|
134
|
-
describe "encodings" do
|
135
|
-
it "should return n3" do subject.to_s.should == "\"15.4\"^^<http://www.w3.org/2001/XMLSchema#float>" end
|
136
|
-
end
|
137
|
-
|
138
|
-
it "should infer type" do
|
139
|
-
float = RDF::Literal.new(15.4)
|
140
|
-
float.datatype.should == RDF::XSD.double
|
141
|
-
end
|
142
|
-
|
143
|
-
it "should have string contents" do subject.value.should == "15.4" end
|
144
|
-
it "should have native contents" do subject.object.should == 15.4 end
|
145
|
-
end
|
146
|
-
|
147
|
-
describe "a date" do
|
148
|
-
before(:each) { @value = Date.parse("2010-01-02Z") }
|
149
|
-
subject { RDF::Literal.new(@value, :datatype => RDF::XSD.date) }
|
150
|
-
describe "encodings" do
|
151
|
-
it "should return n3" do subject.to_s.should == "\"2010-01-02Z\"^^<http://www.w3.org/2001/XMLSchema#date>" end
|
152
|
-
end
|
153
|
-
|
154
|
-
it "should infer type" do
|
155
|
-
int = RDF::Literal.new(@value)
|
156
|
-
int.datatype.should == RDF::XSD.date
|
157
|
-
end
|
158
|
-
|
159
|
-
it "should have string contents" do subject.value.should == "2010-01-02Z" end
|
160
|
-
it "should have native contents" do subject.object.should == @value end
|
161
|
-
end
|
162
|
-
|
163
|
-
describe "a dateTime" do
|
164
|
-
before(:each) { @value = DateTime.parse('2010-01-03T01:02:03Z') }
|
165
|
-
subject { RDF::Literal.new(@value, :datatype => RDF::XSD.dateTime) }
|
166
|
-
describe "encodings" do
|
167
|
-
it "should return n3" do subject.to_s.should == "\"2010-01-03T01:02:03Z\"^^<http://www.w3.org/2001/XMLSchema#dateTime>" end
|
168
|
-
end
|
169
|
-
|
170
|
-
it "should infer type" do
|
171
|
-
int = RDF::Literal.new(@value)
|
172
|
-
int.datatype.should == RDF::XSD.dateTime
|
173
|
-
end
|
174
|
-
|
175
|
-
it "should have string contents" do subject.value.should == "2010-01-03T01:02:03Z" end
|
176
|
-
it "should have native contents" do subject.object.should == @value end
|
177
|
-
end
|
178
|
-
|
179
|
-
describe "a time" do
|
180
|
-
before(:each) { @value = Time.parse('01:02:03Z') }
|
181
|
-
subject { RDF::Literal.new(@value, :datatype => RDF::XSD.time) }
|
182
|
-
describe "encodings" do
|
183
|
-
it "should return n3" do subject.to_s.should == "\"01:02:03Z\"^^<http://www.w3.org/2001/XMLSchema#time>" end
|
184
|
-
end
|
185
|
-
|
186
|
-
it "should infer type" do
|
187
|
-
int = RDF::Literal.new(@value)
|
188
|
-
int.datatype.should == RDF::XSD.time
|
189
|
-
end
|
190
|
-
|
191
|
-
it "should have string contents" do subject.value.should == "01:02:03Z" end
|
192
|
-
it "should have native contents" do subject.object.should == @value end
|
193
|
-
end
|
194
|
-
|
195
12
|
describe "XML Literal" do
|
196
13
|
describe "with no namespace" do
|
197
|
-
subject {
|
198
|
-
it "should
|
199
|
-
subject.xmlliteral?.should == true
|
200
|
-
end
|
201
|
-
|
202
|
-
describe "encodings" do
|
203
|
-
it "should return n3" do subject.to_s.should == "\"foo <sup>bar</sup> baz!\"^^<http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral>" end
|
204
|
-
end
|
205
|
-
|
206
|
-
it "should be equal if they have the same contents" do
|
207
|
-
should == RDF::Literal.new("foo <sup>bar</sup> baz!", :datatype => RDF.XMLLiteral)
|
208
|
-
end
|
14
|
+
subject { @new.call("foo <sup>bar</sup> baz!", :datatype => RDF.XMLLiteral) }
|
15
|
+
it "should return input" do subject.to_s.should == "foo <sup>bar</sup> baz!" end
|
209
16
|
|
210
|
-
it "should be
|
211
|
-
|
17
|
+
it "should be equal if they have the same contents" do
|
18
|
+
should == @new.call("foo <sup>bar</sup> baz!", :datatype => RDF.XMLLiteral)
|
212
19
|
end
|
213
20
|
end
|
214
|
-
|
21
|
+
|
215
22
|
describe "with a namespace" do
|
216
23
|
subject {
|
217
|
-
|
24
|
+
@new.call("foo <dc:sup>bar</dc:sup> baz!", :datatype => RDF.XMLLiteral,
|
218
25
|
:namespaces => {"dc" => RDF::DC.to_s})
|
219
26
|
}
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
end
|
224
|
-
|
27
|
+
|
28
|
+
it "should add namespaces" do subject.to_s.should == "foo <dc:sup xmlns:dc=\"http://purl.org/dc/terms/\">bar</dc:sup> baz!" end
|
29
|
+
|
225
30
|
describe "and language" do
|
226
31
|
subject {
|
227
|
-
|
32
|
+
@new.call("foo <dc:sup>bar</dc:sup> baz!", :datatype => RDF.XMLLiteral,
|
228
33
|
:namespaces => {"dc" => RDF::DC.to_s},
|
229
34
|
:language => :fr)
|
230
35
|
}
|
231
36
|
|
232
|
-
|
233
|
-
it "should return n3" do subject.to_s.should == "\"foo <sup xml:lang=\\\"fr\\\">bar</sup> baz!\"\^^<http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral>" end
|
234
|
-
end
|
37
|
+
it "should add namespaces and language" do subject.to_s.should == "foo <dc:sup xmlns:dc=\"http://purl.org/dc/terms/\" xml:lang=\"fr\">bar</dc:sup> baz!" end
|
235
38
|
end
|
236
|
-
|
39
|
+
|
237
40
|
describe "and language with an existing language embedded" do
|
238
41
|
subject {
|
239
|
-
|
42
|
+
@new.call("foo <dc:sup>bar</dc:sup><dc:sub xml:lang=\"en\">baz</dc:sub>",
|
240
43
|
:datatype => RDF.XMLLiteral,
|
44
|
+
:namespaces => {"dc" => RDF::DC.to_s},
|
241
45
|
:language => :fr)
|
242
46
|
}
|
243
47
|
|
244
|
-
|
245
|
-
it "should return n3" do subject.to_s.should == "\"foo <sup xml:lang=\\\"fr\\\">bar</sup><sub xml:lang=\\\"en\\\">baz</sub>\"^^<http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral>" end
|
246
|
-
end
|
48
|
+
it "should add namespaces and language" do subject.to_s.should == "foo <dc:sup xmlns:dc=\"http://purl.org/dc/terms/\" xml:lang=\"fr\">bar</dc:sup><dc:sub xmlns:dc=\"http://purl.org/dc/terms/\" xml:lang=\"en\">baz</dc:sub>" end
|
247
49
|
end
|
50
|
+
end
|
248
51
|
|
249
52
|
describe "with a default namespace" do
|
250
53
|
subject {
|
251
|
-
|
54
|
+
@new.call("foo <sup>bar</sup> baz!", :datatype => RDF.XMLLiteral,
|
252
55
|
:namespaces => {"" => RDF::DC.to_s})
|
253
56
|
}
|
254
|
-
|
255
|
-
describe "encodings" do
|
256
|
-
it "should return n3" do subject.to_s.should == "\"foo <sup xmlns=\\\"http://purl.org/dc/terms/\\\">bar</sup> baz!\"^^<http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral>" end
|
257
|
-
end
|
258
|
-
end
|
259
|
-
|
260
|
-
describe "with multiple namespaces" do
|
261
|
-
subject {
|
262
|
-
RDF::Literal.new("foo <sup xmlns:dc=\"http://purl.org/dc/terms/\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">bar</sup> baz!", :datatype => RDF.XMLLiteral)
|
263
|
-
}
|
264
|
-
it "should ignore namespace order" do
|
265
|
-
g = RDF::Literal.new("foo <sup xmlns:dc=\"http://purl.org/dc/terms/\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">bar</sup> baz!", :datatype => RDF.XMLLiteral)
|
266
|
-
should == g
|
267
|
-
end
|
268
|
-
end
|
269
|
-
end
|
270
|
-
|
271
|
-
describe "an n3 literal" do
|
272
|
-
{
|
273
|
-
"Gregg" => 'Gregg',
|
274
|
-
"Dürst" => 'D\u00FCrst',
|
275
|
-
"simple literal" => 'simple literal',
|
276
|
-
"backslash:\\" => 'backslash:\\\\',
|
277
|
-
"dquote:\"" => 'dquote:\\"',
|
278
|
-
"newline:\n" => 'newline:\\n',
|
279
|
-
"return:\r" => 'return:\\r',
|
280
|
-
"tab:\t" => 'tab:\\t',
|
281
|
-
}.each_pair do |name, value|
|
282
|
-
specify "test #{name}" do
|
283
|
-
RDF::Literal.new(value.rdf_unescape).value.should == name
|
284
|
-
end
|
285
|
-
end
|
286
|
-
end
|
287
|
-
|
288
|
-
describe "valid content" do
|
289
|
-
{
|
290
|
-
"true" => %("true"^^<http://www.w3.org/2001/XMLSchema#boolean>),
|
291
|
-
"false" => %("false"^^<http://www.w3.org/2001/XMLSchema#boolean>),
|
292
|
-
"tRuE" => %("true"^^<http://www.w3.org/2001/XMLSchema#boolean>),
|
293
|
-
"FaLsE" => %("false"^^<http://www.w3.org/2001/XMLSchema#boolean>),
|
294
|
-
"1" => %("true"^^<http://www.w3.org/2001/XMLSchema#boolean>),
|
295
|
-
"0" => %("false"^^<http://www.w3.org/2001/XMLSchema#boolean>),
|
296
|
-
}.each_pair do |lit, n3|
|
297
|
-
it "should validate boolean '#{lit}'" do
|
298
|
-
RDF::Literal.new(lit, :datatype => RDF::XSD.boolean).valid?.should be_true
|
299
|
-
end
|
300
|
-
|
301
|
-
it "should normalize boolean '#{lit}'" do
|
302
|
-
RDF::Literal.new(lit, :datatype => RDF::XSD.boolean).to_s.should == n3
|
303
|
-
end
|
304
|
-
end
|
305
|
-
|
306
|
-
{
|
307
|
-
"01" => %("1"^^<http://www.w3.org/2001/XMLSchema#integer>),
|
308
|
-
"1" => %("1"^^<http://www.w3.org/2001/XMLSchema#integer>),
|
309
|
-
"-1" => %("-1"^^<http://www.w3.org/2001/XMLSchema#integer>),
|
310
|
-
"+1" => %("1"^^<http://www.w3.org/2001/XMLSchema#integer>),
|
311
|
-
}.each_pair do |lit, n3|
|
312
|
-
it "should validate integer '#{lit}'" do
|
313
|
-
RDF::Literal.new(lit, :datatype => RDF::XSD.integer).valid?.should be_true
|
314
|
-
end
|
315
|
-
|
316
|
-
it "should normalize integer '#{lit}'" do
|
317
|
-
RDF::Literal.new(lit, :datatype => RDF::XSD.integer).to_s.should == n3
|
318
|
-
end
|
319
|
-
end
|
320
|
-
|
321
|
-
{
|
322
|
-
"1" => %("1.0"^^<http://www.w3.org/2001/XMLSchema#decimal>),
|
323
|
-
"-1" => %("-1.0"^^<http://www.w3.org/2001/XMLSchema#decimal>),
|
324
|
-
"1." => %("1.0"^^<http://www.w3.org/2001/XMLSchema#decimal>),
|
325
|
-
"1.0" => %("1.0"^^<http://www.w3.org/2001/XMLSchema#decimal>),
|
326
|
-
"1.00" => %("1.0"^^<http://www.w3.org/2001/XMLSchema#decimal>),
|
327
|
-
"+001.00" => %("1.0"^^<http://www.w3.org/2001/XMLSchema#decimal>),
|
328
|
-
"123.456" => %("123.456"^^<http://www.w3.org/2001/XMLSchema#decimal>),
|
329
|
-
"2.345" => %("2.345"^^<http://www.w3.org/2001/XMLSchema#decimal>),
|
330
|
-
"1.000000000" => %("1.0"^^<http://www.w3.org/2001/XMLSchema#decimal>),
|
331
|
-
"2.3" => %("2.3"^^<http://www.w3.org/2001/XMLSchema#decimal>),
|
332
|
-
"2.234000005" => %("2.234000005"^^<http://www.w3.org/2001/XMLSchema#decimal>),
|
333
|
-
"2.2340000000000005" => %("2.2340000000000005"^^<http://www.w3.org/2001/XMLSchema#decimal>),
|
334
|
-
"2.23400000000000005" => %("2.234"^^<http://www.w3.org/2001/XMLSchema#decimal>),
|
335
|
-
"2.23400000000000000000005" => %("2.234"^^<http://www.w3.org/2001/XMLSchema#decimal>),
|
336
|
-
"1.2345678901234567890123457890" => %("1.2345678901234567"^^<http://www.w3.org/2001/XMLSchema#decimal>),
|
337
|
-
}.each_pair do |lit, n3|
|
338
|
-
it "should validate decimal '#{lit}'" do
|
339
|
-
RDF::Literal.new(lit, :datatype => RDF::XSD.decimal).valid?.should be_true
|
340
|
-
end
|
341
|
-
|
342
|
-
it "should normalize decimal '#{lit}'" do
|
343
|
-
RDF::Literal.new(lit, :datatype => RDF::XSD.decimal).to_s.should == n3
|
344
|
-
end
|
345
|
-
end
|
346
|
-
|
347
|
-
{
|
348
|
-
"1" => %("1.0E0"^^<http://www.w3.org/2001/XMLSchema#double>),
|
349
|
-
"-1" => %("-1.0E0"^^<http://www.w3.org/2001/XMLSchema#double>),
|
350
|
-
"+01.000" => %("1.0E0"^^<http://www.w3.org/2001/XMLSchema#double>),
|
351
|
-
"1." => %("1.0E0"^^<http://www.w3.org/2001/XMLSchema#double>),
|
352
|
-
"1.0" => %("1.0E0"^^<http://www.w3.org/2001/XMLSchema#double>),
|
353
|
-
"123.456" => %("1.23456E2"^^<http://www.w3.org/2001/XMLSchema#double>),
|
354
|
-
"1.0e+1" => %("1.0E1"^^<http://www.w3.org/2001/XMLSchema#double>),
|
355
|
-
"1.0e-10" => %("1.0E-10"^^<http://www.w3.org/2001/XMLSchema#double>),
|
356
|
-
"123.456e4" => %("1.23456E6"^^<http://www.w3.org/2001/XMLSchema#double>),
|
357
|
-
}.each_pair do |lit, n3|
|
358
|
-
it "should validate double '#{lit}'" do
|
359
|
-
RDF::Literal.new(lit, :datatype => RDF::XSD.double).valid?.should be_true
|
360
|
-
end
|
361
57
|
|
362
|
-
it "should
|
363
|
-
RDF::Literal.new(lit, :datatype => RDF::XSD.double).to_s.should == n3
|
364
|
-
end
|
365
|
-
end
|
366
|
-
end
|
367
|
-
|
368
|
-
describe "invalid content" do
|
369
|
-
[
|
370
|
-
RDF::Literal.new("foo", :datatype => RDF::XSD.boolean),
|
371
|
-
RDF::Literal.new("xyz", :datatype => RDF::XSD.integer),
|
372
|
-
RDF::Literal.new("12xyz", :datatype => RDF::XSD.integer),
|
373
|
-
RDF::Literal.new("12.xyz", :datatype => RDF::XSD.decimal),
|
374
|
-
RDF::Literal.new("xy.z", :datatype => RDF::XSD.double),
|
375
|
-
RDF::Literal.new("+1.0z", :datatype => RDF::XSD.double),
|
376
|
-
].each do |lit|
|
377
|
-
it "should detect invalid encoding for '#{lit.to_s}'" do
|
378
|
-
lit.valid?.should be_false
|
379
|
-
end
|
58
|
+
it "should add namespace" do subject.to_s.should == "foo <sup xmlns=\"http://purl.org/dc/terms/\">bar</sup> baz!" end
|
380
59
|
end
|
381
|
-
end
|
60
|
+
end if defined?(::Nokogiri)
|
382
61
|
end
|
data/spec/n3reader_spec.rb
CHANGED
@@ -104,7 +104,7 @@ describe "RDF::N3::Reader" do
|
|
104
104
|
@statement.predicate.to_s.should == "http://xmlns.com/foaf/0.1/name"
|
105
105
|
end
|
106
106
|
it "should have object" do
|
107
|
-
@statement.object.to_s.should ==
|
107
|
+
@statement.object.to_s.should == "Gregg Kellogg"
|
108
108
|
end
|
109
109
|
end
|
110
110
|
|
@@ -303,24 +303,24 @@ describe "RDF::N3::Reader" do
|
|
303
303
|
end
|
304
304
|
end
|
305
305
|
|
306
|
-
describe "with illegal syntax" do
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
end
|
306
|
+
# describe "with illegal syntax" do
|
307
|
+
# {
|
308
|
+
# %(:y :p1 "xyz"^^xsd:integer .) => %r(Typed literal has an invalid lexical value: .* "xyz"),
|
309
|
+
# %(:y :p1 "12xyz"^^xsd:integer .) => %r(Typed literal has an invalid lexical value: .* "12xyz"),
|
310
|
+
# %(:y :p1 "xy.z"^^xsd:double .) => %r(Typed literal has an invalid lexical value: .* "xy\.z"),
|
311
|
+
# %(:y :p1 "+1.0z"^^xsd:double .) => %r(Typed literal has an invalid lexical value: .* "\+1.0z"),
|
312
|
+
# %(:a :b .) => %r(Illegal statment: ".*" missing object),
|
313
|
+
# %(:a :b 'single quote' .) => RDF::ReaderError,
|
314
|
+
# %(:a "literal value" :b .) => RDF::ReaderError,
|
315
|
+
# %(@keywords prefix. :e prefix :f .) => %r(Keyword ".*" used as expression)
|
316
|
+
# }.each_pair do |n3, error|
|
317
|
+
# it "should raise error for '#{n3}'" do
|
318
|
+
# lambda {
|
319
|
+
# parse("@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . #{n3}", :base_uri => "http://a/b")
|
320
|
+
# }.should raise_error(error)
|
321
|
+
# end
|
322
|
+
# end
|
323
|
+
# end
|
324
324
|
|
325
325
|
describe "with n3 grammer" do
|
326
326
|
describe "syntactic expressions" do
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rdf-n3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 25
|
5
4
|
prerelease: false
|
6
5
|
segments:
|
7
6
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
7
|
+
- 2
|
8
|
+
- 1
|
9
|
+
version: 0.2.1
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- Gregg Kellogg
|
@@ -15,34 +14,30 @@ autorequire:
|
|
15
14
|
bindir: bin
|
16
15
|
cert_chain: []
|
17
16
|
|
18
|
-
date: 2010-06-
|
17
|
+
date: 2010-06-28 00:00:00 -07:00
|
19
18
|
default_executable:
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
22
21
|
name: rdf
|
23
22
|
prerelease: false
|
24
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
24
|
requirements:
|
27
25
|
- - ">="
|
28
26
|
- !ruby/object:Gem::Version
|
29
|
-
hash: 23
|
30
27
|
segments:
|
31
28
|
- 0
|
32
29
|
- 2
|
33
|
-
-
|
34
|
-
version: 0.2.
|
30
|
+
- 1
|
31
|
+
version: 0.2.1
|
35
32
|
type: :runtime
|
36
33
|
version_requirements: *id001
|
37
34
|
- !ruby/object:Gem::Dependency
|
38
35
|
name: treetop
|
39
36
|
prerelease: false
|
40
37
|
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
38
|
requirements:
|
43
39
|
- - ">="
|
44
40
|
- !ruby/object:Gem::Version
|
45
|
-
hash: 7
|
46
41
|
segments:
|
47
42
|
- 1
|
48
43
|
- 4
|
@@ -54,11 +49,9 @@ dependencies:
|
|
54
49
|
name: rspec
|
55
50
|
prerelease: false
|
56
51
|
requirement: &id003 !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
52
|
requirements:
|
59
53
|
- - ">="
|
60
54
|
- !ruby/object:Gem::Version
|
61
|
-
hash: 3
|
62
55
|
segments:
|
63
56
|
- 0
|
64
57
|
version: "0"
|
@@ -68,41 +61,37 @@ dependencies:
|
|
68
61
|
name: rdf-spec
|
69
62
|
prerelease: false
|
70
63
|
requirement: &id004 !ruby/object:Gem::Requirement
|
71
|
-
none: false
|
72
64
|
requirements:
|
73
65
|
- - ">="
|
74
66
|
- !ruby/object:Gem::Version
|
75
|
-
hash: 3
|
76
67
|
segments:
|
77
68
|
- 0
|
78
|
-
|
69
|
+
- 2
|
70
|
+
- 1
|
71
|
+
version: 0.2.1
|
79
72
|
type: :development
|
80
73
|
version_requirements: *id004
|
81
74
|
- !ruby/object:Gem::Dependency
|
82
75
|
name: rdf-rdfxml
|
83
76
|
prerelease: false
|
84
77
|
requirement: &id005 !ruby/object:Gem::Requirement
|
85
|
-
none: false
|
86
78
|
requirements:
|
87
79
|
- - ">="
|
88
80
|
- !ruby/object:Gem::Version
|
89
|
-
hash: 23
|
90
81
|
segments:
|
91
82
|
- 0
|
92
83
|
- 2
|
93
|
-
-
|
94
|
-
version: 0.2.
|
84
|
+
- 1
|
85
|
+
version: 0.2.1
|
95
86
|
type: :development
|
96
87
|
version_requirements: *id005
|
97
88
|
- !ruby/object:Gem::Dependency
|
98
89
|
name: rdf-isomorphic
|
99
90
|
prerelease: false
|
100
91
|
requirement: &id006 !ruby/object:Gem::Requirement
|
101
|
-
none: false
|
102
92
|
requirements:
|
103
93
|
- - ">="
|
104
94
|
- !ruby/object:Gem::Version
|
105
|
-
hash: 3
|
106
95
|
segments:
|
107
96
|
- 0
|
108
97
|
version: "0"
|
@@ -112,11 +101,9 @@ dependencies:
|
|
112
101
|
name: yard
|
113
102
|
prerelease: false
|
114
103
|
requirement: &id007 !ruby/object:Gem::Requirement
|
115
|
-
none: false
|
116
104
|
requirements:
|
117
105
|
- - ">="
|
118
106
|
- !ruby/object:Gem::Version
|
119
|
-
hash: 3
|
120
107
|
segments:
|
121
108
|
- 0
|
122
109
|
version: "0"
|
@@ -145,10 +132,8 @@ files:
|
|
145
132
|
- lib/rdf/n3/format.rb
|
146
133
|
- lib/rdf/n3/patches/array_hacks.rb
|
147
134
|
- lib/rdf/n3/patches/graph_properties.rb
|
148
|
-
- lib/rdf/n3/patches/literal_hacks.rb
|
149
135
|
- lib/rdf/n3/patches/literal_normalization.rb
|
150
136
|
- lib/rdf/n3/patches/qname_hacks.rb
|
151
|
-
- lib/rdf/n3/patches/rdf_escape.rb
|
152
137
|
- lib/rdf/n3/patches/seq.rb
|
153
138
|
- lib/rdf/n3/patches/uri_hacks.rb
|
154
139
|
- lib/rdf/n3/reader.rb
|
@@ -718,7 +703,6 @@ files:
|
|
718
703
|
- spec/turtle/test-29.ttl
|
719
704
|
- spec/turtle/test-30.out
|
720
705
|
- spec/turtle/test-30.ttl
|
721
|
-
- spec/turtle_serializer_spec.rb
|
722
706
|
- spec/turtle_spec.rb
|
723
707
|
- spec/writer_spec.rb
|
724
708
|
has_rdoc: true
|
@@ -731,27 +715,23 @@ rdoc_options:
|
|
731
715
|
require_paths:
|
732
716
|
- lib
|
733
717
|
required_ruby_version: !ruby/object:Gem::Requirement
|
734
|
-
none: false
|
735
718
|
requirements:
|
736
719
|
- - ">="
|
737
720
|
- !ruby/object:Gem::Version
|
738
|
-
hash: 3
|
739
721
|
segments:
|
740
722
|
- 0
|
741
723
|
version: "0"
|
742
724
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
743
|
-
none: false
|
744
725
|
requirements:
|
745
726
|
- - ">="
|
746
727
|
- !ruby/object:Gem::Version
|
747
|
-
hash: 3
|
748
728
|
segments:
|
749
729
|
- 0
|
750
730
|
version: "0"
|
751
731
|
requirements: []
|
752
732
|
|
753
733
|
rubyforge_project:
|
754
|
-
rubygems_version: 1.3.
|
734
|
+
rubygems_version: 1.3.6
|
755
735
|
signing_key:
|
756
736
|
specification_version: 3
|
757
737
|
summary: Notation-3 (n3-rdf) and Turtle reader/writer for RDF.rb.
|
@@ -764,6 +744,5 @@ test_files:
|
|
764
744
|
- spec/rdf_helper.rb
|
765
745
|
- spec/spec_helper.rb
|
766
746
|
- spec/swap_spec.rb
|
767
|
-
- spec/turtle_serializer_spec.rb
|
768
747
|
- spec/turtle_spec.rb
|
769
748
|
- spec/writer_spec.rb
|
@@ -1,23 +0,0 @@
|
|
1
|
-
module RDF
|
2
|
-
class Literal
|
3
|
-
# Support for XML Literals
|
4
|
-
# Is this an XMLLiteral?
|
5
|
-
def xmlliteral?
|
6
|
-
datatype == RDF['XMLLiteral']
|
7
|
-
end
|
8
|
-
|
9
|
-
def anonymous?; false; end unless respond_to?(:anonymous?)
|
10
|
-
|
11
|
-
##
|
12
|
-
# Returns a string representation of this literal.
|
13
|
-
#
|
14
|
-
# @return [String]
|
15
|
-
def to_s
|
16
|
-
quoted = value # FIXME
|
17
|
-
output = "\"#{quoted.to_s.rdf_escape}\""
|
18
|
-
output << "@#{language}" if has_language? && !has_datatype?
|
19
|
-
output << "^^<#{datatype}>" if has_datatype?
|
20
|
-
output
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|