rdf-turtle 1.0.9 → 1.1.0p0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +8 -11
- data/VERSION +1 -1
- data/lib/rdf/turtle/meta.rb +117 -108
- data/lib/rdf/turtle/reader.rb +31 -30
- data/lib/rdf/turtle/terminals.rb +15 -59
- data/lib/rdf/turtle/writer.rb +32 -57
- metadata +32 -13
- checksums.yaml +0 -15
- data/lib/rdf/turtle/streaming_writer.rb +0 -52
data/README.md
CHANGED
@@ -15,8 +15,7 @@ Install with `gem install rdf-turtle`
|
|
15
15
|
|
16
16
|
* 100% free and unencumbered [public domain](http://unlicense.org/) software.
|
17
17
|
* Implements a complete parser for [Turtle][].
|
18
|
-
* Compatible with Ruby
|
19
|
-
* Optional streaming writer, to serialize large graphs
|
18
|
+
* Compatible with Ruby >= 1.9.2.
|
20
19
|
|
21
20
|
## Usage
|
22
21
|
Instantiate a reader from a local file:
|
@@ -46,18 +45,16 @@ Full documentation available on [Rubydoc.info][Turtle doc]
|
|
46
45
|
### Variations from the spec
|
47
46
|
In some cases, the specification is unclear on certain issues:
|
48
47
|
|
49
|
-
*
|
50
|
-
|
51
|
-
|
52
|
-
syntax where the `@` and closing `.` are optional and `base/prefix` are matched case independently.
|
53
|
-
* Additionally, both `a` and `A` match `rdf:type`.
|
48
|
+
* For the time being, plain literals are generated without an xsd:string datatype, but literals with an xsd:string
|
49
|
+
datatype are saved as non-datatyped triples in the graph. This will be updated in the future when the rest of the
|
50
|
+
library suite is brought up to date with RDF 1.1.
|
54
51
|
|
55
52
|
### Freebase-specific Reader
|
56
53
|
There is a special reader useful for processing [Freebase Dumps][]. To invoke
|
57
54
|
this, add the `:freebase => true` option to the {RDF::Turtle::Reader.new}, or
|
58
55
|
use {RDF::Turtle::FreebaseReader} directly. As with {RDF::Turtle::Reader},
|
59
56
|
prefix definitions may be passed in using the `:prefixes` option to
|
60
|
-
RDF::Turtle::FreebaseReader} using the standard mechanism defined
|
57
|
+
{RDF::Turtle::FreebaseReader#initialize} using the standard mechanism defined
|
61
58
|
for `RDF::Reader`.
|
62
59
|
|
63
60
|
The [Freebase Dumps][] have a very normalized form, similar to N-Triples but
|
@@ -93,9 +90,9 @@ using the [EBNF][] gem.
|
|
93
90
|
|
94
91
|
## Dependencies
|
95
92
|
|
96
|
-
* [Ruby](http://ruby-lang.org/) (>= 1.
|
97
|
-
* [RDF.rb](http://rubygems.org/gems/rdf) (>= 1.
|
98
|
-
* [EBNF][] (>= 0.
|
93
|
+
* [Ruby](http://ruby-lang.org/) (>= 1.9.2)
|
94
|
+
* [RDF.rb](http://rubygems.org/gems/rdf) (>= 1.1)
|
95
|
+
* [EBNF][] (>= 0.3.0)
|
99
96
|
|
100
97
|
## Installation
|
101
98
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.1.0p0
|
data/lib/rdf/turtle/meta.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# This file is automatically generated by /Users/gregg/.rvm/gems/ruby-1.9.3-
|
1
|
+
# This file is automatically generated by /Users/gregg/.rvm/gems/ruby-1.9.3-p374/bundler/gems/ebnf-a5c008da3a01/bin/ebnf
|
2
2
|
# BRANCH derived from etc/turtle.bnf
|
3
3
|
module RDF::Turtle::Meta
|
4
4
|
START = :turtleDoc
|
@@ -66,19 +66,7 @@ module RDF::Turtle::Meta
|
|
66
66
|
:STRING_LITERAL_SINGLE_QUOTE => [:STRING_LITERAL_SINGLE_QUOTE],
|
67
67
|
},
|
68
68
|
:base => {
|
69
|
-
|
70
|
-
},
|
71
|
-
:_base_1 => {
|
72
|
-
"(" => [],
|
73
|
-
"." => ["."],
|
74
|
-
:ANON => [],
|
75
|
-
:BASE => [],
|
76
|
-
:BLANK_NODE_LABEL => [],
|
77
|
-
:IRIREF => [],
|
78
|
-
:PNAME_LN => [],
|
79
|
-
:PNAME_NS => [],
|
80
|
-
:PREFIX => [],
|
81
|
-
"[" => [],
|
69
|
+
"@base" => ["@base", :IRIREF, "."],
|
82
70
|
},
|
83
71
|
:blankNodePropertyList => {
|
84
72
|
"[" => ["[", :predicateObjectList, "]"],
|
@@ -124,8 +112,10 @@ module RDF::Turtle::Meta
|
|
124
112
|
"true" => [:object, :_collection_1],
|
125
113
|
},
|
126
114
|
:directive => {
|
127
|
-
|
128
|
-
|
115
|
+
"@base" => [:base],
|
116
|
+
"@prefix" => [:prefixID],
|
117
|
+
:SPARQL_BASE => [:sparqlBase],
|
118
|
+
:SPARQL_PREFIX => [:sparqlPrefix],
|
129
119
|
},
|
130
120
|
:iri => {
|
131
121
|
:IRIREF => [:IRIREF],
|
@@ -229,29 +219,25 @@ module RDF::Turtle::Meta
|
|
229
219
|
"a" => [:verb, :objectList],
|
230
220
|
},
|
231
221
|
:prefixID => {
|
232
|
-
|
222
|
+
"@prefix" => ["@prefix", :PNAME_NS, :IRIREF, "."],
|
233
223
|
},
|
234
|
-
:
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
:
|
239
|
-
:BLANK_NODE_LABEL => [],
|
240
|
-
:IRIREF => [],
|
241
|
-
:PNAME_LN => [],
|
242
|
-
:PNAME_NS => [],
|
243
|
-
:PREFIX => [],
|
244
|
-
"[" => [],
|
224
|
+
:sparqlBase => {
|
225
|
+
:SPARQL_BASE => [:SPARQL_BASE, :IRIREF],
|
226
|
+
},
|
227
|
+
:sparqlPrefix => {
|
228
|
+
:SPARQL_PREFIX => [:SPARQL_PREFIX, :PNAME_NS, :IRIREF],
|
245
229
|
},
|
246
230
|
:statement => {
|
247
231
|
"(" => [:_statement_1],
|
232
|
+
"@base" => [:directive],
|
233
|
+
"@prefix" => [:directive],
|
248
234
|
:ANON => [:_statement_1],
|
249
|
-
:BASE => [:directive],
|
250
235
|
:BLANK_NODE_LABEL => [:_statement_1],
|
251
236
|
:IRIREF => [:_statement_1],
|
252
237
|
:PNAME_LN => [:_statement_1],
|
253
238
|
:PNAME_NS => [:_statement_1],
|
254
|
-
:
|
239
|
+
:SPARQL_BASE => [:directive],
|
240
|
+
:SPARQL_PREFIX => [:directive],
|
255
241
|
"[" => [:_statement_1],
|
256
242
|
},
|
257
243
|
:_statement_1 => {
|
@@ -300,24 +286,28 @@ module RDF::Turtle::Meta
|
|
300
286
|
},
|
301
287
|
:turtleDoc => {
|
302
288
|
"(" => [:_turtleDoc_1],
|
289
|
+
"@base" => [:_turtleDoc_1],
|
290
|
+
"@prefix" => [:_turtleDoc_1],
|
303
291
|
:ANON => [:_turtleDoc_1],
|
304
|
-
:BASE => [:_turtleDoc_1],
|
305
292
|
:BLANK_NODE_LABEL => [:_turtleDoc_1],
|
306
293
|
:IRIREF => [:_turtleDoc_1],
|
307
294
|
:PNAME_LN => [:_turtleDoc_1],
|
308
295
|
:PNAME_NS => [:_turtleDoc_1],
|
309
|
-
:
|
296
|
+
:SPARQL_BASE => [:_turtleDoc_1],
|
297
|
+
:SPARQL_PREFIX => [:_turtleDoc_1],
|
310
298
|
"[" => [:_turtleDoc_1],
|
311
299
|
},
|
312
300
|
:_turtleDoc_1 => {
|
313
301
|
"(" => [:statement, :turtleDoc],
|
302
|
+
"@base" => [:statement, :turtleDoc],
|
303
|
+
"@prefix" => [:statement, :turtleDoc],
|
314
304
|
:ANON => [:statement, :turtleDoc],
|
315
|
-
:BASE => [:statement, :turtleDoc],
|
316
305
|
:BLANK_NODE_LABEL => [:statement, :turtleDoc],
|
317
306
|
:IRIREF => [:statement, :turtleDoc],
|
318
307
|
:PNAME_LN => [:statement, :turtleDoc],
|
319
308
|
:PNAME_NS => [:statement, :turtleDoc],
|
320
|
-
:
|
309
|
+
:SPARQL_BASE => [:statement, :turtleDoc],
|
310
|
+
:SPARQL_PREFIX => [:statement, :turtleDoc],
|
321
311
|
"[" => [:statement, :turtleDoc],
|
322
312
|
},
|
323
313
|
:verb => {
|
@@ -333,8 +323,9 @@ module RDF::Turtle::Meta
|
|
333
323
|
",",
|
334
324
|
".",
|
335
325
|
";",
|
326
|
+
"@base",
|
327
|
+
"@prefix",
|
336
328
|
:ANON,
|
337
|
-
:BASE,
|
338
329
|
:BLANK_NODE_LABEL,
|
339
330
|
:DECIMAL,
|
340
331
|
:DOUBLE,
|
@@ -343,7 +334,8 @@ module RDF::Turtle::Meta
|
|
343
334
|
:LANGTAG,
|
344
335
|
:PNAME_LN,
|
345
336
|
:PNAME_NS,
|
346
|
-
:
|
337
|
+
:SPARQL_BASE,
|
338
|
+
:SPARQL_PREFIX,
|
347
339
|
:STRING_LITERAL_LONG_QUOTE,
|
348
340
|
:STRING_LITERAL_LONG_SINGLE_QUOTE,
|
349
341
|
:STRING_LITERAL_QUOTE,
|
@@ -393,15 +385,9 @@ module RDF::Turtle::Meta
|
|
393
385
|
:STRING_LITERAL_LONG_SINGLE_QUOTE,
|
394
386
|
:STRING_LITERAL_LONG_QUOTE],
|
395
387
|
:base => [
|
396
|
-
|
388
|
+
"@base"],
|
397
389
|
:_base_1 => [
|
398
|
-
".",
|
399
|
-
:_eps],
|
400
|
-
:_base_2 => [
|
401
390
|
:IRIREF],
|
402
|
-
:_base_3 => [
|
403
|
-
".",
|
404
|
-
:_eps],
|
405
391
|
:blankNodePropertyList => [
|
406
392
|
"["],
|
407
393
|
:_blankNodePropertyList_1 => [
|
@@ -487,8 +473,10 @@ module RDF::Turtle::Meta
|
|
487
473
|
:_collection_5 => [
|
488
474
|
")"],
|
489
475
|
:directive => [
|
490
|
-
|
491
|
-
|
476
|
+
"@prefix",
|
477
|
+
"@base",
|
478
|
+
:SPARQL_PREFIX,
|
479
|
+
:SPARQL_BASE],
|
492
480
|
:_empty => [
|
493
481
|
:_eps],
|
494
482
|
:iri => [
|
@@ -640,20 +628,22 @@ module RDF::Turtle::Meta
|
|
640
628
|
:STRING_LITERAL_LONG_SINGLE_QUOTE,
|
641
629
|
:STRING_LITERAL_LONG_QUOTE],
|
642
630
|
:prefixID => [
|
643
|
-
|
631
|
+
"@prefix"],
|
644
632
|
:_prefixID_1 => [
|
645
|
-
".",
|
646
|
-
:_eps],
|
647
|
-
:_prefixID_2 => [
|
648
633
|
:PNAME_NS],
|
649
|
-
:
|
634
|
+
:sparqlBase => [
|
635
|
+
:SPARQL_BASE],
|
636
|
+
:_sparqlBase_1 => [
|
650
637
|
:IRIREF],
|
651
|
-
:
|
652
|
-
|
653
|
-
|
638
|
+
:sparqlPrefix => [
|
639
|
+
:SPARQL_PREFIX],
|
640
|
+
:_sparqlPrefix_1 => [
|
641
|
+
:PNAME_NS],
|
654
642
|
:statement => [
|
655
|
-
|
656
|
-
|
643
|
+
"@prefix",
|
644
|
+
"@base",
|
645
|
+
:SPARQL_PREFIX,
|
646
|
+
:SPARQL_BASE,
|
657
647
|
"[",
|
658
648
|
:IRIREF,
|
659
649
|
:BLANK_NODE_LABEL,
|
@@ -714,8 +704,10 @@ module RDF::Turtle::Meta
|
|
714
704
|
:PNAME_NS],
|
715
705
|
:turtleDoc => [
|
716
706
|
:_eps,
|
717
|
-
|
718
|
-
|
707
|
+
"@prefix",
|
708
|
+
"@base",
|
709
|
+
:SPARQL_PREFIX,
|
710
|
+
:SPARQL_BASE,
|
719
711
|
"[",
|
720
712
|
:IRIREF,
|
721
713
|
:BLANK_NODE_LABEL,
|
@@ -724,8 +716,10 @@ module RDF::Turtle::Meta
|
|
724
716
|
:PNAME_LN,
|
725
717
|
:PNAME_NS],
|
726
718
|
:_turtleDoc_1 => [
|
727
|
-
|
728
|
-
|
719
|
+
"@prefix",
|
720
|
+
"@base",
|
721
|
+
:SPARQL_PREFIX,
|
722
|
+
:SPARQL_BASE,
|
729
723
|
"[",
|
730
724
|
:IRIREF,
|
731
725
|
:BLANK_NODE_LABEL,
|
@@ -735,8 +729,10 @@ module RDF::Turtle::Meta
|
|
735
729
|
:PNAME_NS],
|
736
730
|
:_turtleDoc_2 => [
|
737
731
|
:_eps,
|
738
|
-
|
739
|
-
|
732
|
+
"@prefix",
|
733
|
+
"@base",
|
734
|
+
:SPARQL_PREFIX,
|
735
|
+
:SPARQL_BASE,
|
740
736
|
"[",
|
741
737
|
:IRIREF,
|
742
738
|
:BLANK_NODE_LABEL,
|
@@ -977,8 +973,10 @@ module RDF::Turtle::Meta
|
|
977
973
|
:STRING_LITERAL_LONG_QUOTE],
|
978
974
|
:base => [
|
979
975
|
:_eof,
|
980
|
-
|
981
|
-
|
976
|
+
"@prefix",
|
977
|
+
"@base",
|
978
|
+
:SPARQL_PREFIX,
|
979
|
+
:SPARQL_BASE,
|
982
980
|
"[",
|
983
981
|
:IRIREF,
|
984
982
|
:BLANK_NODE_LABEL,
|
@@ -988,30 +986,10 @@ module RDF::Turtle::Meta
|
|
988
986
|
:PNAME_NS],
|
989
987
|
:_base_1 => [
|
990
988
|
:_eof,
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
:
|
995
|
-
:BLANK_NODE_LABEL,
|
996
|
-
:ANON,
|
997
|
-
"(",
|
998
|
-
:PNAME_LN,
|
999
|
-
:PNAME_NS],
|
1000
|
-
:_base_2 => [
|
1001
|
-
:_eof,
|
1002
|
-
:PREFIX,
|
1003
|
-
:BASE,
|
1004
|
-
"[",
|
1005
|
-
:IRIREF,
|
1006
|
-
:BLANK_NODE_LABEL,
|
1007
|
-
:ANON,
|
1008
|
-
"(",
|
1009
|
-
:PNAME_LN,
|
1010
|
-
:PNAME_NS],
|
1011
|
-
:_base_3 => [
|
1012
|
-
:_eof,
|
1013
|
-
:PREFIX,
|
1014
|
-
:BASE,
|
989
|
+
"@prefix",
|
990
|
+
"@base",
|
991
|
+
:SPARQL_PREFIX,
|
992
|
+
:SPARQL_BASE,
|
1015
993
|
"[",
|
1016
994
|
:IRIREF,
|
1017
995
|
:BLANK_NODE_LABEL,
|
@@ -1165,8 +1143,10 @@ module RDF::Turtle::Meta
|
|
1165
1143
|
:STRING_LITERAL_LONG_QUOTE],
|
1166
1144
|
:directive => [
|
1167
1145
|
:_eof,
|
1168
|
-
|
1169
|
-
|
1146
|
+
"@prefix",
|
1147
|
+
"@base",
|
1148
|
+
:SPARQL_PREFIX,
|
1149
|
+
:SPARQL_BASE,
|
1170
1150
|
"[",
|
1171
1151
|
:IRIREF,
|
1172
1152
|
:BLANK_NODE_LABEL,
|
@@ -1330,8 +1310,10 @@ module RDF::Turtle::Meta
|
|
1330
1310
|
"]"],
|
1331
1311
|
:prefixID => [
|
1332
1312
|
:_eof,
|
1333
|
-
|
1334
|
-
|
1313
|
+
"@prefix",
|
1314
|
+
"@base",
|
1315
|
+
:SPARQL_PREFIX,
|
1316
|
+
:SPARQL_BASE,
|
1335
1317
|
"[",
|
1336
1318
|
:IRIREF,
|
1337
1319
|
:BLANK_NODE_LABEL,
|
@@ -1341,8 +1323,23 @@ module RDF::Turtle::Meta
|
|
1341
1323
|
:PNAME_NS],
|
1342
1324
|
:_prefixID_1 => [
|
1343
1325
|
:_eof,
|
1344
|
-
|
1345
|
-
|
1326
|
+
"@prefix",
|
1327
|
+
"@base",
|
1328
|
+
:SPARQL_PREFIX,
|
1329
|
+
:SPARQL_BASE,
|
1330
|
+
"[",
|
1331
|
+
:IRIREF,
|
1332
|
+
:BLANK_NODE_LABEL,
|
1333
|
+
:ANON,
|
1334
|
+
"(",
|
1335
|
+
:PNAME_LN,
|
1336
|
+
:PNAME_NS],
|
1337
|
+
:sparqlBase => [
|
1338
|
+
:_eof,
|
1339
|
+
"@prefix",
|
1340
|
+
"@base",
|
1341
|
+
:SPARQL_PREFIX,
|
1342
|
+
:SPARQL_BASE,
|
1346
1343
|
"[",
|
1347
1344
|
:IRIREF,
|
1348
1345
|
:BLANK_NODE_LABEL,
|
@@ -1350,10 +1347,12 @@ module RDF::Turtle::Meta
|
|
1350
1347
|
"(",
|
1351
1348
|
:PNAME_LN,
|
1352
1349
|
:PNAME_NS],
|
1353
|
-
:
|
1350
|
+
:_sparqlBase_1 => [
|
1354
1351
|
:_eof,
|
1355
|
-
|
1356
|
-
|
1352
|
+
"@prefix",
|
1353
|
+
"@base",
|
1354
|
+
:SPARQL_PREFIX,
|
1355
|
+
:SPARQL_BASE,
|
1357
1356
|
"[",
|
1358
1357
|
:IRIREF,
|
1359
1358
|
:BLANK_NODE_LABEL,
|
@@ -1361,10 +1360,12 @@ module RDF::Turtle::Meta
|
|
1361
1360
|
"(",
|
1362
1361
|
:PNAME_LN,
|
1363
1362
|
:PNAME_NS],
|
1364
|
-
:
|
1363
|
+
:sparqlPrefix => [
|
1365
1364
|
:_eof,
|
1366
|
-
|
1367
|
-
|
1365
|
+
"@prefix",
|
1366
|
+
"@base",
|
1367
|
+
:SPARQL_PREFIX,
|
1368
|
+
:SPARQL_BASE,
|
1368
1369
|
"[",
|
1369
1370
|
:IRIREF,
|
1370
1371
|
:BLANK_NODE_LABEL,
|
@@ -1372,10 +1373,12 @@ module RDF::Turtle::Meta
|
|
1372
1373
|
"(",
|
1373
1374
|
:PNAME_LN,
|
1374
1375
|
:PNAME_NS],
|
1375
|
-
:
|
1376
|
+
:_sparqlPrefix_1 => [
|
1376
1377
|
:_eof,
|
1377
|
-
|
1378
|
-
|
1378
|
+
"@prefix",
|
1379
|
+
"@base",
|
1380
|
+
:SPARQL_PREFIX,
|
1381
|
+
:SPARQL_BASE,
|
1379
1382
|
"[",
|
1380
1383
|
:IRIREF,
|
1381
1384
|
:BLANK_NODE_LABEL,
|
@@ -1385,8 +1388,10 @@ module RDF::Turtle::Meta
|
|
1385
1388
|
:PNAME_NS],
|
1386
1389
|
:statement => [
|
1387
1390
|
:_eof,
|
1388
|
-
|
1389
|
-
|
1391
|
+
"@prefix",
|
1392
|
+
"@base",
|
1393
|
+
:SPARQL_PREFIX,
|
1394
|
+
:SPARQL_BASE,
|
1390
1395
|
"[",
|
1391
1396
|
:IRIREF,
|
1392
1397
|
:BLANK_NODE_LABEL,
|
@@ -1396,8 +1401,10 @@ module RDF::Turtle::Meta
|
|
1396
1401
|
:PNAME_NS],
|
1397
1402
|
:_statement_1 => [
|
1398
1403
|
:_eof,
|
1399
|
-
|
1400
|
-
|
1404
|
+
"@prefix",
|
1405
|
+
"@base",
|
1406
|
+
:SPARQL_PREFIX,
|
1407
|
+
:SPARQL_BASE,
|
1401
1408
|
"[",
|
1402
1409
|
:IRIREF,
|
1403
1410
|
:BLANK_NODE_LABEL,
|
@@ -1407,8 +1414,10 @@ module RDF::Turtle::Meta
|
|
1407
1414
|
:PNAME_NS],
|
1408
1415
|
:_statement_2 => [
|
1409
1416
|
:_eof,
|
1410
|
-
|
1411
|
-
|
1417
|
+
"@prefix",
|
1418
|
+
"@base",
|
1419
|
+
:SPARQL_PREFIX,
|
1420
|
+
:SPARQL_BASE,
|
1412
1421
|
"[",
|
1413
1422
|
:IRIREF,
|
1414
1423
|
:BLANK_NODE_LABEL,
|
data/lib/rdf/turtle/reader.rb
CHANGED
@@ -67,58 +67,54 @@ module RDF::Turtle
|
|
67
67
|
end
|
68
68
|
|
69
69
|
# String terminals
|
70
|
-
terminal(nil, %r([\(\),.;\[\]
|
70
|
+
terminal(nil, %r([\(\),.;\[\]a]|\^\^|@base|@prefix|true|false)) do |prod, token, input|
|
71
71
|
case token.value
|
72
|
-
when '
|
72
|
+
when 'a' then input[:resource] = RDF.type
|
73
73
|
when 'true', 'false' then input[:resource] = RDF::Literal::Boolean.new(token.value)
|
74
74
|
when '@base', '@prefix' then input[:lang] = token.value[1..-1]
|
75
|
-
when '.' then input[:terminated] = true
|
76
75
|
else input[:string] = token.value
|
77
76
|
end
|
78
77
|
end
|
79
78
|
|
80
|
-
terminal(:PREFIX, PREFIX) do |prod, token, input|
|
81
|
-
input[:string_value] = token.value
|
82
|
-
end
|
83
|
-
terminal(:BASE, BASE) do |prod, token, input|
|
84
|
-
input[:string_value] = token.value
|
85
|
-
end
|
86
|
-
|
87
79
|
terminal(:LANGTAG, LANGTAG) do |prod, token, input|
|
88
80
|
input[:lang] = token.value[1..-1]
|
89
81
|
end
|
90
82
|
|
83
|
+
terminal(:SPARQL_PREFIX, SPARQL_PREFIX) do |prod, token, input|
|
84
|
+
input[:string_value] = token.value.downcase
|
85
|
+
end
|
86
|
+
terminal(:SPARQL_BASE, SPARQL_BASE) do |prod, token, input|
|
87
|
+
input[:string_value] = token.value.downcase
|
88
|
+
end
|
89
|
+
|
91
90
|
# Productions
|
92
91
|
# [4] prefixID defines a prefix mapping
|
93
92
|
production(:prefixID) do |input, current, callback|
|
94
93
|
prefix = current[:prefix]
|
95
94
|
iri = current[:resource]
|
96
|
-
lexical = current[:string_value]
|
97
|
-
terminated = current[:terminated]
|
98
95
|
debug("prefixID") {"Defined prefix #{prefix.inspect} mapping to #{iri.inspect}"}
|
99
|
-
if lexical.start_with?('@') && lexical != '@prefix'
|
100
|
-
error(:prefixID, "should be downcased")
|
101
|
-
elsif lexical == '@prefix'
|
102
|
-
error(:prefixID, "directive not terminated") unless terminated
|
103
|
-
else
|
104
|
-
error(:prefixID, "directive should not be terminated") if terminated
|
105
|
-
end
|
106
96
|
prefix(prefix, iri)
|
107
97
|
end
|
108
98
|
|
109
99
|
# [5] base set base_uri
|
110
100
|
production(:base) do |input, current, callback|
|
111
101
|
iri = current[:resource]
|
112
|
-
lexical = current[:string_value]
|
113
|
-
terminated = current[:terminated]
|
114
102
|
debug("base") {"Defined base as #{iri}"}
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
103
|
+
options[:base_uri] = iri
|
104
|
+
end
|
105
|
+
|
106
|
+
# [28s] sparqlPrefix ::= [Pp][Rr][Ee][Ff][Ii][Xx] PNAME_NS IRIREF
|
107
|
+
production(:sparqlPrefix) do |input, current, callback|
|
108
|
+
prefix = current[:prefix]
|
109
|
+
iri = current[:resource]
|
110
|
+
debug("sparqlPrefix") {"Defined prefix #{prefix.inspect} mapping to #{iri.inspect}"}
|
111
|
+
prefix(prefix, iri)
|
112
|
+
end
|
113
|
+
|
114
|
+
# [29s] sparqlBase ::= [Bb][Aa][Ss][Ee] IRIREF
|
115
|
+
production(:sparqlBase) do |input, current, callback|
|
116
|
+
iri = current[:resource]
|
117
|
+
debug("base") {"Defined base as #{iri}"}
|
122
118
|
options[:base_uri] = iri
|
123
119
|
end
|
124
120
|
|
@@ -180,15 +176,20 @@ module RDF::Turtle
|
|
180
176
|
|
181
177
|
production(:collection) do |input, current, callback|
|
182
178
|
# Create an RDF list
|
179
|
+
bnode = self.bnode
|
183
180
|
objects = current[:object_list]
|
184
|
-
list = RDF::List
|
181
|
+
list = RDF::List.new(bnode, nil, objects)
|
185
182
|
list.each_statement do |statement|
|
183
|
+
# Spec Confusion, referenced section "Collection" is missing from the spec.
|
184
|
+
# Anicdodal evidence indicates that some expect each node to be of type rdf:list,
|
185
|
+
# but existing Notation3 and Turtle tests (http://www.w3.org/2001/sw/DataAccess/df1/tests/manifest.ttl) do not.
|
186
186
|
next if statement.predicate == RDF.type && statement.object == RDF.List
|
187
187
|
callback.call(:statement, "collection", statement.subject, statement.predicate, statement.object)
|
188
188
|
end
|
189
|
+
bnode = RDF.nil if list.empty?
|
189
190
|
|
190
191
|
# Return bnode as resource
|
191
|
-
input[:resource] =
|
192
|
+
input[:resource] = bnode
|
192
193
|
end
|
193
194
|
|
194
195
|
# [16] RDFLiteral ::= String ( LanguageTag | ( "^^" IRIref ) )?
|
data/lib/rdf/turtle/terminals.rb
CHANGED
@@ -4,60 +4,16 @@ module RDF::Turtle
|
|
4
4
|
module Terminals
|
5
5
|
# Definitions of token regular expressions used for lexical analysis
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
IRI_RANGE = Regexp.compile("[[^<>\"{}|^`\\\\]&&[^\\x00-\\x20]]").freeze
|
18
|
-
else
|
19
|
-
##
|
20
|
-
# UTF-8 regular expressions for Ruby 1.8.x.
|
21
|
-
U_CHARS1 = Regexp.compile(<<-EOS.gsub(/\s+/, ''))
|
22
|
-
\\xC3[\\x80-\\x96]| (?# [\\u00C0-\\u00D6]|)
|
23
|
-
\\xC3[\\x98-\\xB6]| (?# [\\u00D8-\\u00F6]|)
|
24
|
-
\\xC3[\\xB8-\\xBF]|[\\xC4-\\xCB][\\x80-\\xBF]| (?# [\\u00F8-\\u02FF]|)
|
25
|
-
\\xCD[\\xB0-\\xBD]| (?# [\\u0370-\\u037D]|)
|
26
|
-
\\xCD\\xBF|[\\xCE-\\xDF][\\x80-\\xBF]| (?# [\\u037F-\\u1FFF]|)
|
27
|
-
\\xE0[\\xA0-\\xBF][\\x80-\\xBF]| (?# ...)
|
28
|
-
\\xE1[\\x80-\\xBF][\\x80-\\xBF]| (?# ...)
|
29
|
-
\\xE2\\x80[\\x8C-\\x8D]| (?# [\\u200C-\\u200D]|)
|
30
|
-
\\xE2\\x81[\\xB0-\\xBF]| (?# [\\u2070-\\u218F]|)
|
31
|
-
\\xE2[\\x82-\\x85][\\x80-\\xBF]| (?# ...)
|
32
|
-
\\xE2\\x86[\\x80-\\x8F]| (?# ...)
|
33
|
-
\\xE2[\\xB0-\\xBE][\\x80-\\xBF]| (?# [\\u2C00-\\u2FEF]|)
|
34
|
-
\\xE2\\xBF[\\x80-\\xAF]| (?# ...)
|
35
|
-
\\xE3\\x80[\\x81-\\xBF]| (?# [\\u3001-\\uD7FF]|)
|
36
|
-
\\xE3[\\x81-\\xBF][\\x80-\\xBF]| (?# ...)
|
37
|
-
[\\xE4-\\xEC][\\x80-\\xBF][\\x80-\\xBF]| (?# ...)
|
38
|
-
\\xED[\\x80-\\x9F][\\x80-\\xBF]| (?# ...)
|
39
|
-
\\xEF[\\xA4-\\xB6][\\x80-\\xBF]| (?# [\\uF900-\\uFDCF]|)
|
40
|
-
\\xEF\\xB7[\\x80-\\x8F]| (?# ...)
|
41
|
-
\\xEF\\xB7[\\xB0-\\xBF]| (?# [\\uFDF0-\\uFFFD]|)
|
42
|
-
\\xEF[\\xB8-\\xBE][\\x80-\\xBF]| (?# ...)
|
43
|
-
\\xEF\\xBF[\\x80-\\xBD]| (?# ...)
|
44
|
-
\\xF0[\\x90-\\xBF][\\x80-\\xBF][\\x80-\\xBF]| (?# [\\u{10000}-\\u{EFFFF}])
|
45
|
-
[\\xF1-\\xF2][\\x80-\\xBF][\\x80-\\xBF][\\x80-\\xBF]|
|
46
|
-
\\xF3[\\x80-\\xAF][\\x80-\\xBF][\\x80-\\xBF] (?# ...)
|
47
|
-
EOS
|
48
|
-
U_CHARS2 = Regexp.compile(<<-EOS.gsub(/\s+/, ''))
|
49
|
-
\\xC2\\xB7| (?# \\u00B7|)
|
50
|
-
\\xCC[\\x80-\\xBF]|\\xCD[\\x80-\\xAF]| (?# [\\u0300-\\u036F]|)
|
51
|
-
\\xE2\\x80\\xBF|\\xE2\\x81\\x80 (?# [\\u203F-\\u2040])
|
52
|
-
EOS
|
53
|
-
IRI_RANGE = Regexp.compile(<<-EOS.gsub(/\s+/, ''))
|
54
|
-
\\x21| (?# ")
|
55
|
-
[\\x23-\\x3b]|\\x3d| (?# < & >)
|
56
|
-
[\\x3f-\\x5b]|\\x5d|\\x5f| (?# \ ^ `)
|
57
|
-
[\\x61-\\x7a]| (?# { } |)
|
58
|
-
[\\x7e-\\xff]
|
59
|
-
EOS
|
60
|
-
end
|
7
|
+
##
|
8
|
+
# Unicode regular expressions for Ruby 1.9+ with the Oniguruma engine.
|
9
|
+
U_CHARS1 = Regexp.compile(<<-EOS.gsub(/\s+/, ''))
|
10
|
+
[\\u00C0-\\u00D6]|[\\u00D8-\\u00F6]|[\\u00F8-\\u02FF]|
|
11
|
+
[\\u0370-\\u037D]|[\\u037F-\\u1FFF]|[\\u200C-\\u200D]|
|
12
|
+
[\\u2070-\\u218F]|[\\u2C00-\\u2FEF]|[\\u3001-\\uD7FF]|
|
13
|
+
[\\uF900-\\uFDCF]|[\\uFDF0-\\uFFFD]|[\\u{10000}-\\u{EFFFF}]
|
14
|
+
EOS
|
15
|
+
U_CHARS2 = Regexp.compile("\\u00B7|[\\u0300-\\u036F]|[\\u203F-\\u2040]").freeze
|
16
|
+
IRI_RANGE = Regexp.compile("[[^<>\"{}|^`\\\\]&&[^\\x00-\\x20]]").freeze
|
61
17
|
|
62
18
|
# 26
|
63
19
|
UCHAR = EBNF::LL1::Lexer::UCHAR
|
@@ -100,22 +56,22 @@ module RDF::Turtle
|
|
100
56
|
# 21
|
101
57
|
DOUBLE = /[+-]?(?:[0-9]+\.[0-9]*#{EXPONENT}|\.?[0-9]+#{EXPONENT})/.freeze
|
102
58
|
# 22
|
103
|
-
|
59
|
+
STRING_LITERAL_QUOTE = /'(?:[^\'\\\n\r]|#{ECHAR}|#{UCHAR})*'/.freeze
|
104
60
|
# 23
|
105
|
-
|
61
|
+
STRING_LITERAL_SINGLE_QUOTE = /"(?:[^\"\\\n\r]|#{ECHAR}|#{UCHAR})*"/.freeze.freeze
|
106
62
|
# 24
|
107
63
|
STRING_LITERAL_LONG_SINGLE_QUOTE = /'''(?:(?:'|'')?(?:[^'\\]|#{ECHAR}|#{UCHAR}))*'''/m.freeze
|
108
64
|
# 25
|
109
|
-
STRING_LITERAL_LONG_QUOTE
|
65
|
+
STRING_LITERAL_LONG_QUOTE = /"""(?:(?:"|"")?(?:[^"\\]|#{ECHAR}|#{UCHAR}))*"""/m.freeze
|
110
66
|
|
111
67
|
# 161s
|
112
68
|
WS = / |\t|\r|\n /.freeze
|
113
69
|
# 162s
|
114
70
|
ANON = /\[#{WS}*\]/m.freeze
|
115
71
|
# 28t
|
116
|
-
|
72
|
+
SPARQL_PREFIX = /prefix/i.freeze
|
117
73
|
# 29t
|
118
|
-
|
74
|
+
SPARQL_BASE = /base/i.freeze
|
119
75
|
|
120
76
|
end
|
121
77
|
end
|
data/lib/rdf/turtle/writer.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'rdf/turtle/terminals'
|
2
|
-
require 'rdf/turtle/streaming_writer'
|
3
2
|
|
4
3
|
module RDF::Turtle
|
5
4
|
##
|
@@ -35,13 +34,6 @@ module RDF::Turtle
|
|
35
34
|
# end
|
36
35
|
# end
|
37
36
|
#
|
38
|
-
# @example Serializing RDF statements to a string in streaming mode
|
39
|
-
# RDF::Turtle::Writer.buffer(:stream => true) do |writer|
|
40
|
-
# graph.each_statement do |statement|
|
41
|
-
# writer << statement
|
42
|
-
# end
|
43
|
-
# end
|
44
|
-
#
|
45
37
|
# The writer will add prefix definitions, and use them for creating @prefix definitions, and minting QNames
|
46
38
|
#
|
47
39
|
# @example Creating @base and @prefix definitions in output
|
@@ -56,11 +48,12 @@ module RDF::Turtle
|
|
56
48
|
#
|
57
49
|
# @author [Gregg Kellogg](http://greggkellogg.net/)
|
58
50
|
class Writer < RDF::Writer
|
59
|
-
include StreamingWriter
|
60
51
|
format RDF::Turtle::Format
|
61
52
|
|
62
53
|
# @return [Graph] Graph of statements serialized
|
63
54
|
attr_accessor :graph
|
55
|
+
# @return [URI] Base URI used for relativizing URIs
|
56
|
+
attr_accessor :base_uri
|
64
57
|
|
65
58
|
##
|
66
59
|
# Initializes the Turtle writer instance.
|
@@ -70,7 +63,7 @@ module RDF::Turtle
|
|
70
63
|
# @param [Hash{Symbol => Object}] options
|
71
64
|
# any additional options
|
72
65
|
# @option options [Encoding] :encoding (Encoding::UTF_8)
|
73
|
-
# the encoding to use on the output stream
|
66
|
+
# the encoding to use on the output stream
|
74
67
|
# @option options [Boolean] :canonicalize (false)
|
75
68
|
# whether to canonicalize literals when serializing
|
76
69
|
# @option options [Hash] :prefixes (Hash.new)
|
@@ -81,8 +74,6 @@ module RDF::Turtle
|
|
81
74
|
# Maximum depth for recursively defining resources, defaults to 3
|
82
75
|
# @option options [Boolean] :standard_prefixes (false)
|
83
76
|
# Add standard prefixes to @prefixes, if necessary.
|
84
|
-
# @option options [Boolean] :stream (false)
|
85
|
-
# Do not attempt to optimize graph presentation, suitable for streaming large graphs.
|
86
77
|
# @option options [String] :default_namespace (nil)
|
87
78
|
# URI to use as default namespace, same as `prefixes[nil]`
|
88
79
|
# @yield [writer] `self`
|
@@ -91,11 +82,10 @@ module RDF::Turtle
|
|
91
82
|
# @yield [writer]
|
92
83
|
# @yieldparam [RDF::Writer] writer
|
93
84
|
def initialize(output = $stdout, options = {}, &block)
|
94
|
-
reset
|
95
|
-
@graph = RDF::Graph.new
|
96
|
-
@uri_to_pname = {}
|
97
|
-
@uri_to_prefix = {}
|
98
85
|
super do
|
86
|
+
@graph = RDF::Graph.new
|
87
|
+
@uri_to_pname = {}
|
88
|
+
@uri_to_prefix = {}
|
99
89
|
if block_given?
|
100
90
|
case block.arity
|
101
91
|
when 0 then instance_eval(&block)
|
@@ -105,18 +95,21 @@ module RDF::Turtle
|
|
105
95
|
end
|
106
96
|
end
|
107
97
|
|
98
|
+
##
|
99
|
+
# Write whole graph
|
100
|
+
#
|
101
|
+
# @param [Graph] graph
|
102
|
+
# @return [void]
|
103
|
+
def write_graph(graph)
|
104
|
+
@graph = graph
|
105
|
+
end
|
106
|
+
|
108
107
|
##
|
109
108
|
# Adds a statement to be serialized
|
110
109
|
# @param [RDF::Statement] statement
|
111
110
|
# @return [void]
|
112
111
|
def write_statement(statement)
|
113
|
-
|
114
|
-
when @options[:stream]
|
115
|
-
stream_statement(statement)
|
116
|
-
else
|
117
|
-
# Add to local graph and output in epilogue
|
118
|
-
@graph.insert(statement)
|
119
|
-
end
|
112
|
+
@graph.insert(statement)
|
120
113
|
end
|
121
114
|
|
122
115
|
##
|
@@ -125,19 +118,10 @@ module RDF::Turtle
|
|
125
118
|
# @param [RDF::URI] predicate
|
126
119
|
# @param [RDF::Value] object
|
127
120
|
# @return [void]
|
121
|
+
# @raise [NotImplementedError] unless implemented in subclass
|
122
|
+
# @abstract
|
128
123
|
def write_triple(subject, predicate, object)
|
129
|
-
|
130
|
-
end
|
131
|
-
|
132
|
-
##
|
133
|
-
# Write out declarations
|
134
|
-
# @return [void] `self`
|
135
|
-
def write_prologue
|
136
|
-
case
|
137
|
-
when @options[:stream]
|
138
|
-
stream_prologue
|
139
|
-
else
|
140
|
-
end
|
124
|
+
@graph.insert(Statement.new(subject, predicate, object))
|
141
125
|
end
|
142
126
|
|
143
127
|
##
|
@@ -146,23 +130,19 @@ module RDF::Turtle
|
|
146
130
|
# @return [void]
|
147
131
|
# @see #write_triple
|
148
132
|
def write_epilogue
|
149
|
-
|
150
|
-
|
151
|
-
stream_epilogue
|
152
|
-
else
|
153
|
-
@max_depth = @options[:max_depth] || 3
|
133
|
+
@max_depth = @options[:max_depth] || 3
|
134
|
+
@base_uri = RDF::URI(@options[:base_uri])
|
154
135
|
|
155
|
-
|
136
|
+
self.reset
|
156
137
|
|
157
|
-
|
138
|
+
debug("\nserialize") {"graph: #{@graph.size}"}
|
158
139
|
|
159
|
-
|
160
|
-
|
140
|
+
preprocess
|
141
|
+
start_document
|
161
142
|
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
end
|
143
|
+
order_subjects.each do |subject|
|
144
|
+
unless is_done?(subject)
|
145
|
+
statement(subject)
|
166
146
|
end
|
167
147
|
end
|
168
148
|
end
|
@@ -320,8 +300,8 @@ module RDF::Turtle
|
|
320
300
|
|
321
301
|
# Start with base_uri
|
322
302
|
if base_uri && @subjects.keys.include?(base_uri)
|
323
|
-
subjects <<
|
324
|
-
seen[
|
303
|
+
subjects << base_uri
|
304
|
+
seen[base_uri] = true
|
325
305
|
end
|
326
306
|
|
327
307
|
# Add distinguished classes
|
@@ -348,16 +328,11 @@ module RDF::Turtle
|
|
348
328
|
(@options[:prefixes] || {}).each_pair do |k, v|
|
349
329
|
@uri_to_prefix[v.to_s] = k
|
350
330
|
end
|
331
|
+
@options[:prefixes] = {} # Will define actual used when matched
|
351
332
|
|
352
333
|
prefix(nil, @options[:default_namespace]) if @options[:default_namespace]
|
353
334
|
|
354
|
-
|
355
|
-
when @options[:stream]
|
356
|
-
else
|
357
|
-
@options[:prefixes] = {} # Will define actual used when matched
|
358
|
-
|
359
|
-
@graph.each {|statement| preprocess_statement(statement)}
|
360
|
-
end
|
335
|
+
@graph.each {|statement| preprocess_statement(statement)}
|
361
336
|
end
|
362
337
|
|
363
338
|
# Perform any statement preprocessing required. This is used to perform reference counts and determine required
|
metadata
CHANGED
@@ -1,32 +1,36 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rdf-turtle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0p0
|
5
|
+
prerelease: 5
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- Gregg Kellogg
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2013-
|
12
|
+
date: 2013-05-11 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: rdf
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
16
18
|
requirements:
|
17
19
|
- - ! '>='
|
18
20
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.
|
21
|
+
version: '1.1'
|
20
22
|
type: :runtime
|
21
23
|
prerelease: false
|
22
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
23
26
|
requirements:
|
24
27
|
- - ! '>='
|
25
28
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.
|
29
|
+
version: '1.1'
|
27
30
|
- !ruby/object:Gem::Dependency
|
28
31
|
name: ebnf
|
29
32
|
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
30
34
|
requirements:
|
31
35
|
- - ! '>='
|
32
36
|
- !ruby/object:Gem::Version
|
@@ -34,6 +38,7 @@ dependencies:
|
|
34
38
|
type: :runtime
|
35
39
|
prerelease: false
|
36
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
37
42
|
requirements:
|
38
43
|
- - ! '>='
|
39
44
|
- !ruby/object:Gem::Version
|
@@ -41,6 +46,7 @@ dependencies:
|
|
41
46
|
- !ruby/object:Gem::Dependency
|
42
47
|
name: open-uri-cached
|
43
48
|
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
44
50
|
requirements:
|
45
51
|
- - ! '>='
|
46
52
|
- !ruby/object:Gem::Version
|
@@ -48,6 +54,7 @@ dependencies:
|
|
48
54
|
type: :development
|
49
55
|
prerelease: false
|
50
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
51
58
|
requirements:
|
52
59
|
- - ! '>='
|
53
60
|
- !ruby/object:Gem::Version
|
@@ -55,6 +62,7 @@ dependencies:
|
|
55
62
|
- !ruby/object:Gem::Dependency
|
56
63
|
name: rspec
|
57
64
|
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
58
66
|
requirements:
|
59
67
|
- - ! '>='
|
60
68
|
- !ruby/object:Gem::Version
|
@@ -62,6 +70,7 @@ dependencies:
|
|
62
70
|
type: :development
|
63
71
|
prerelease: false
|
64
72
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
65
74
|
requirements:
|
66
75
|
- - ! '>='
|
67
76
|
- !ruby/object:Gem::Version
|
@@ -69,6 +78,7 @@ dependencies:
|
|
69
78
|
- !ruby/object:Gem::Dependency
|
70
79
|
name: rdf-isomorphic
|
71
80
|
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
72
82
|
requirements:
|
73
83
|
- - ! '>='
|
74
84
|
- !ruby/object:Gem::Version
|
@@ -76,6 +86,7 @@ dependencies:
|
|
76
86
|
type: :development
|
77
87
|
prerelease: false
|
78
88
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
79
90
|
requirements:
|
80
91
|
- - ! '>='
|
81
92
|
- !ruby/object:Gem::Version
|
@@ -83,6 +94,7 @@ dependencies:
|
|
83
94
|
- !ruby/object:Gem::Dependency
|
84
95
|
name: json-ld
|
85
96
|
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
86
98
|
requirements:
|
87
99
|
- - ! '>='
|
88
100
|
- !ruby/object:Gem::Version
|
@@ -90,6 +102,7 @@ dependencies:
|
|
90
102
|
type: :development
|
91
103
|
prerelease: false
|
92
104
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
93
106
|
requirements:
|
94
107
|
- - ! '>='
|
95
108
|
- !ruby/object:Gem::Version
|
@@ -97,6 +110,7 @@ dependencies:
|
|
97
110
|
- !ruby/object:Gem::Dependency
|
98
111
|
name: yard
|
99
112
|
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
100
114
|
requirements:
|
101
115
|
- - ! '>='
|
102
116
|
- !ruby/object:Gem::Version
|
@@ -104,6 +118,7 @@ dependencies:
|
|
104
118
|
type: :development
|
105
119
|
prerelease: false
|
106
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
107
122
|
requirements:
|
108
123
|
- - ! '>='
|
109
124
|
- !ruby/object:Gem::Version
|
@@ -111,20 +126,23 @@ dependencies:
|
|
111
126
|
- !ruby/object:Gem::Dependency
|
112
127
|
name: rdf-spec
|
113
128
|
requirement: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
114
130
|
requirements:
|
115
131
|
- - ! '>='
|
116
132
|
- !ruby/object:Gem::Version
|
117
|
-
version: '1.
|
133
|
+
version: '1.1'
|
118
134
|
type: :development
|
119
135
|
prerelease: false
|
120
136
|
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
121
138
|
requirements:
|
122
139
|
- - ! '>='
|
123
140
|
- !ruby/object:Gem::Version
|
124
|
-
version: '1.
|
141
|
+
version: '1.1'
|
125
142
|
- !ruby/object:Gem::Dependency
|
126
143
|
name: rake
|
127
144
|
requirement: !ruby/object:Gem::Requirement
|
145
|
+
none: false
|
128
146
|
requirements:
|
129
147
|
- - ! '>='
|
130
148
|
- !ruby/object:Gem::Version
|
@@ -132,6 +150,7 @@ dependencies:
|
|
132
150
|
type: :development
|
133
151
|
prerelease: false
|
134
152
|
version_requirements: !ruby/object:Gem::Requirement
|
153
|
+
none: false
|
135
154
|
requirements:
|
136
155
|
- - ! '>='
|
137
156
|
- !ruby/object:Gem::Version
|
@@ -151,7 +170,6 @@ files:
|
|
151
170
|
- lib/rdf/turtle/freebase_reader.rb
|
152
171
|
- lib/rdf/turtle/meta.rb
|
153
172
|
- lib/rdf/turtle/reader.rb
|
154
|
-
- lib/rdf/turtle/streaming_writer.rb
|
155
173
|
- lib/rdf/turtle/terminals.rb
|
156
174
|
- lib/rdf/turtle/version.rb
|
157
175
|
- lib/rdf/turtle/writer.rb
|
@@ -159,26 +177,27 @@ files:
|
|
159
177
|
homepage: http://ruby-rdf.github.com/rdf-turtle
|
160
178
|
licenses:
|
161
179
|
- Public Domain
|
162
|
-
metadata: {}
|
163
180
|
post_install_message:
|
164
181
|
rdoc_options: []
|
165
182
|
require_paths:
|
166
183
|
- lib
|
167
184
|
required_ruby_version: !ruby/object:Gem::Requirement
|
185
|
+
none: false
|
168
186
|
requirements:
|
169
187
|
- - ! '>='
|
170
188
|
- !ruby/object:Gem::Version
|
171
|
-
version: 1.
|
189
|
+
version: 1.9.2
|
172
190
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
191
|
+
none: false
|
173
192
|
requirements:
|
174
|
-
- - ! '
|
193
|
+
- - ! '>'
|
175
194
|
- !ruby/object:Gem::Version
|
176
|
-
version:
|
195
|
+
version: 1.3.1
|
177
196
|
requirements: []
|
178
197
|
rubyforge_project: rdf-turtle
|
179
|
-
rubygems_version:
|
198
|
+
rubygems_version: 1.8.25
|
180
199
|
signing_key:
|
181
|
-
specification_version:
|
200
|
+
specification_version: 3
|
182
201
|
summary: Turtle reader/writer for Ruby.
|
183
202
|
test_files: []
|
184
203
|
has_rdoc: false
|
checksums.yaml
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
---
|
2
|
-
!binary "U0hBMQ==":
|
3
|
-
metadata.gz: !binary |-
|
4
|
-
MWFjZTgwYTA4YmJmMDk2NDZkZGQ1YjA3MTkxMmY1ZDFhM2ViMDBlNg==
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
MDhmM2ZlOWEwYjdlYmY4MWU4NTM1YmY3MjdlOTFiOTEwOGU4NWYzMQ==
|
7
|
-
!binary "U0hBNTEy":
|
8
|
-
metadata.gz: !binary |-
|
9
|
-
NDQ3ODc2YWMwY2I5YzhlOGY0ZmQxOThhMzcyM2U5ZDE4OTU3NDNmNjFkZjVl
|
10
|
-
YWU0MTg3Y2I3MDQzN2Q4MDYxNDlkMzVjYTFhZDZhMWY4ZmQzNjBjNzkyZWRk
|
11
|
-
NjBiYzVjY2RmNGY2MjUzNzQyMzIxNjI5M2E4YjI4OTc4NGJlYTE=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
ODQ3Njk3ZWM3NGFiZGJlNzE2ODcxMzRiNGQ0Mjg5NzIzYmI0Y2EzMDQyN2Rj
|
14
|
-
YWI4ZjA3M2EzMjJjMzliMTgyYjRmNmM2MDdkYzAzYjRmMjgwYzkwOGVkZDk3
|
15
|
-
NGY0MmY2MmVkZmVhOGFlYWY1MTMwMTdjYmQ2NDQ5NTk1NzZiNDQ=
|
@@ -1,52 +0,0 @@
|
|
1
|
-
require 'rdf/turtle/terminals'
|
2
|
-
|
3
|
-
module RDF::Turtle
|
4
|
-
##
|
5
|
-
# Streaming writer interface
|
6
|
-
# @author [Gregg Kellogg](http://greggkellogg.net/)
|
7
|
-
module StreamingWriter
|
8
|
-
##
|
9
|
-
# Write out declarations
|
10
|
-
# @return [void] `self`
|
11
|
-
def stream_prologue
|
12
|
-
if @options[:standard_prefixes]
|
13
|
-
RDF::Vocabulary.each do |vocab|
|
14
|
-
pfx = vocab.__name__.to_s.split('::').last.downcase
|
15
|
-
prefix(pfx, vocab.to_uri)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
preprocess
|
19
|
-
start_document
|
20
|
-
@output.puts ""
|
21
|
-
self
|
22
|
-
end
|
23
|
-
|
24
|
-
##
|
25
|
-
# Write out a statement, retaining current
|
26
|
-
# `subject` and `predicate` to create more compact output
|
27
|
-
# @return [void] `self`
|
28
|
-
def stream_statement(statement)
|
29
|
-
if statement.subject != @streaming_subject
|
30
|
-
@output.puts ' .' if @streaming_subject
|
31
|
-
@streaming_subject, @streaming_predicate = statement.subject, statement.predicate
|
32
|
-
@output.write "#{format_term(statement.subject)} "
|
33
|
-
@output.write "#{format_term(statement.predicate)} "
|
34
|
-
elsif statement.predicate != @streaming_predicate
|
35
|
-
@streaming_predicate = statement.predicate
|
36
|
-
@output.write ";\n#{indent(1)}#{format_term(statement.predicate)} "
|
37
|
-
else
|
38
|
-
@output.write ",\n#{indent(2)}"
|
39
|
-
end
|
40
|
-
@output.write("#{format_term(statement.object)}")
|
41
|
-
end
|
42
|
-
|
43
|
-
##
|
44
|
-
# Complete open statements
|
45
|
-
# @return [void] `self`
|
46
|
-
def stream_epilogue
|
47
|
-
@output.puts ' .' if @streaming_subject
|
48
|
-
end
|
49
|
-
|
50
|
-
private
|
51
|
-
end
|
52
|
-
end
|