rdf-turtle 1.1.2 → 1.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/rdf/turtle/writer.rb +31 -24
- metadata +37 -31
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e70f98dd4b68010ecd944b0adaab421d282fc68
|
4
|
+
data.tar.gz: c8133157388afcc8b8fdfaef1cdc7818cf8ee101
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b0f9a3588b5e5f1e0ac0745d3a197bc28a90b49afdd616812af04c6149283e6037c0365cacb52b26ef6def7a61e8747e8bf36db12684447bd637e90885c84a6
|
7
|
+
data.tar.gz: 9a9286be339a48c7697a8886008d781c3fb7ef030b319d979e81bb98be36c009230c1eae80886e7fc8e5b9f239b583982fdb3b9945c5e71c2d786d6a92e39b14
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.1.
|
1
|
+
1.1.3
|
data/lib/rdf/turtle/writer.rb
CHANGED
@@ -266,7 +266,7 @@ module RDF::Turtle
|
|
266
266
|
# @return [String]
|
267
267
|
def format_uri(uri, options = {})
|
268
268
|
md = relativize(uri)
|
269
|
-
debug("relativize") {"#{uri.
|
269
|
+
debug("relativize") {"#{uri.to_ntriples} => #{md.inspect}"} if md != uri.to_s
|
270
270
|
md != uri.to_s ? "<#{md}>" : (get_pname(uri) || "<#{uri}>")
|
271
271
|
end
|
272
272
|
|
@@ -325,7 +325,7 @@ module RDF::Turtle
|
|
325
325
|
# Add distinguished classes
|
326
326
|
top_classes.each do |class_uri|
|
327
327
|
graph.query(:predicate => RDF.type, :object => class_uri).map {|st| st.subject}.sort.uniq.each do |subject|
|
328
|
-
debug("order_subjects") {subject.
|
328
|
+
debug("order_subjects") {subject.to_ntriples}
|
329
329
|
subjects << subject
|
330
330
|
seen[subject] = true
|
331
331
|
end
|
@@ -362,7 +362,7 @@ module RDF::Turtle
|
|
362
362
|
# prefixes.
|
363
363
|
# @param [Statement] statement
|
364
364
|
def preprocess_statement(statement)
|
365
|
-
#debug("preprocess") {statement.
|
365
|
+
#debug("preprocess") {statement.to_ntriples}
|
366
366
|
bump_reference(statement.object)
|
367
367
|
@subjects[statement.subject] = true
|
368
368
|
|
@@ -413,11 +413,12 @@ module RDF::Turtle
|
|
413
413
|
return unless @options[:debug] || RDF::Turtle.debug?
|
414
414
|
options = args.last.is_a?(Hash) ? args.pop : {}
|
415
415
|
depth = options[:depth] || @depth
|
416
|
+
d_str = depth > 100 ? ' ' * 100 + '+' : ' ' * depth
|
416
417
|
message = args.pop
|
417
418
|
message = message.call if message.is_a?(Proc)
|
418
419
|
args << message if message
|
419
420
|
args << yield if block_given?
|
420
|
-
message = "#{args.join(': ')}"
|
421
|
+
message = "#{d_str}#{args.join(': ')}"
|
421
422
|
@options[:debug] << message if @options[:debug].is_a?(Array)
|
422
423
|
$stderr.puts(message) if RDF::Turtle.debug?
|
423
424
|
end
|
@@ -445,7 +446,7 @@ module RDF::Turtle
|
|
445
446
|
|
446
447
|
def collection(node, position)
|
447
448
|
return false if !is_valid_list?(node)
|
448
|
-
#debug("collection") {"#{node.
|
449
|
+
#debug("collection") {"#{node.to_ntriples}, #{position}"}
|
449
450
|
|
450
451
|
@output.write(position == :subject ? "(" : " (")
|
451
452
|
@depth += 2
|
@@ -454,31 +455,31 @@ module RDF::Turtle
|
|
454
455
|
@output.write(')')
|
455
456
|
end
|
456
457
|
|
457
|
-
# Can object be represented using a
|
458
|
+
# Can object be represented using a blankNodePropertyList?
|
458
459
|
def p_squared?(resource, position)
|
459
460
|
resource.is_a?(RDF::Node) &&
|
460
461
|
!@serialized.has_key?(resource) &&
|
461
462
|
ref_count(resource) <= 1
|
462
463
|
end
|
463
464
|
|
464
|
-
# Represent an object as a
|
465
|
+
# Represent an object as a blankNodePropertyList
|
465
466
|
def p_squared(resource, position)
|
466
467
|
return false unless p_squared?(resource, position)
|
467
468
|
|
468
|
-
#debug("p_squared") {"#{resource.
|
469
|
+
#debug("p_squared") {"#{resource.to_ntriples}, #{position}"}
|
469
470
|
subject_done(resource)
|
470
471
|
@output.write(position == :subject ? '[' : ' [')
|
471
472
|
@depth += 2
|
472
|
-
predicateObjectList(resource)
|
473
|
+
num_props = predicateObjectList(resource, true)
|
474
|
+
@output.write(num_props > 1 ? "\n#{indent} ]" : "]")
|
473
475
|
@depth -= 2
|
474
|
-
@output.write(']')
|
475
476
|
|
476
477
|
true
|
477
478
|
end
|
478
479
|
|
479
480
|
# Default singular resource representation.
|
480
481
|
def p_default(resource, position)
|
481
|
-
#debug("p_default") {"#{resource.
|
482
|
+
#debug("p_default") {"#{resource.to_ntriples}, #{position}"}
|
482
483
|
l = (position == :subject ? "" : " ") + format_value(resource)
|
483
484
|
@output.write(l)
|
484
485
|
end
|
@@ -487,17 +488,17 @@ module RDF::Turtle
|
|
487
488
|
# Use either collection, blankNodePropertyList or singular resource notation.
|
488
489
|
def path(resource, position)
|
489
490
|
debug("path") do
|
490
|
-
"#{resource.
|
491
|
+
"#{resource.to_ntriples}, " +
|
491
492
|
"pos: #{position}, " +
|
492
|
-
"
|
493
|
-
"
|
493
|
+
"()?: #{is_valid_list?(resource)}, " +
|
494
|
+
"[]?: #{p_squared?(resource, position)}, " +
|
494
495
|
"rc: #{ref_count(resource)}"
|
495
496
|
end
|
496
497
|
raise RDF::WriterError, "Cannot serialize resource '#{resource}'" unless collection(resource, position) || p_squared(resource, position) || p_default(resource, position)
|
497
498
|
end
|
498
499
|
|
499
500
|
def predicate(resource)
|
500
|
-
debug("predicate") {resource.
|
501
|
+
debug("predicate") {resource.to_ntriples}
|
501
502
|
if resource == RDF.type
|
502
503
|
@output.write(" a")
|
503
504
|
else
|
@@ -511,23 +512,28 @@ module RDF::Turtle
|
|
511
512
|
return if objects.empty?
|
512
513
|
|
513
514
|
objects.each_with_index do |obj, i|
|
514
|
-
|
515
|
+
if i > 0 && p_squared?(obj, :object)
|
516
|
+
@output.write ", "
|
517
|
+
elsif i > 0
|
518
|
+
@output.write ",\n#{indent(4)}"
|
519
|
+
end
|
515
520
|
path(obj, :object)
|
516
521
|
end
|
517
522
|
end
|
518
523
|
|
519
524
|
# Render a predicateObjectList having a common subject.
|
520
|
-
|
525
|
+
# @return [Integer] the number of properties serialized
|
526
|
+
def predicateObjectList(subject, from_bpl = false)
|
521
527
|
properties = {}
|
522
528
|
@graph.query(:subject => subject) do |st|
|
523
|
-
properties[st.predicate.to_s] ||= []
|
524
|
-
properties[st.predicate.to_s] << st.object
|
529
|
+
(properties[st.predicate.to_s] ||= []) << st.object
|
525
530
|
end
|
526
531
|
|
527
532
|
prop_list = sort_properties(properties) - [RDF.first.to_s, RDF.rest.to_s]
|
528
533
|
debug("predicateObjectList") {prop_list.inspect}
|
529
|
-
return if prop_list.empty?
|
534
|
+
return 0 if prop_list.empty?
|
530
535
|
|
536
|
+
@output.write("\n#{indent(2)}") if properties.keys.length > 1 && from_bpl
|
531
537
|
prop_list.each_with_index do |prop, i|
|
532
538
|
begin
|
533
539
|
@output.write(";\n#{indent(2)}") if i > 0
|
@@ -536,6 +542,7 @@ module RDF::Turtle
|
|
536
542
|
objectList(properties[prop])
|
537
543
|
end
|
538
544
|
end
|
545
|
+
properties.keys.length
|
539
546
|
end
|
540
547
|
|
541
548
|
# Can subject be represented as a blankNodePropertyList?
|
@@ -547,12 +554,12 @@ module RDF::Turtle
|
|
547
554
|
def blankNodePropertyList(subject)
|
548
555
|
return false unless blankNodePropertyList?(subject)
|
549
556
|
|
550
|
-
debug("blankNodePropertyList") {subject.
|
557
|
+
debug("blankNodePropertyList") {subject.to_ntriples}
|
551
558
|
@output.write("\n#{indent} [")
|
552
559
|
@depth += 1
|
553
|
-
predicateObjectList(subject)
|
560
|
+
num_props = predicateObjectList(subject, true)
|
554
561
|
@depth -= 1
|
555
|
-
@output.write("] .")
|
562
|
+
@output.write(num_props > 1 ? "\n#{indent} ] ." : "] .")
|
556
563
|
true
|
557
564
|
end
|
558
565
|
|
@@ -566,7 +573,7 @@ module RDF::Turtle
|
|
566
573
|
end
|
567
574
|
|
568
575
|
def statement(subject)
|
569
|
-
debug("statement") {"#{subject.
|
576
|
+
debug("statement") {"#{subject.to_ntriples}, bnodePL?: #{blankNodePropertyList?(subject)}"}
|
570
577
|
subject_done(subject)
|
571
578
|
blankNodePropertyList(subject) || triples(subject)
|
572
579
|
@output.puts
|
metadata
CHANGED
@@ -1,139 +1,145 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rdf-turtle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gregg Kellogg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-03-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rdf
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.1
|
19
|
+
version: '1.1'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 1.1.2.1
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
|
-
- -
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.1'
|
30
|
+
- - ">="
|
25
31
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.1.
|
32
|
+
version: 1.1.2.1
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: ebnf
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
30
36
|
requirements:
|
31
|
-
- -
|
37
|
+
- - ">="
|
32
38
|
- !ruby/object:Gem::Version
|
33
39
|
version: 0.3.5
|
34
40
|
type: :runtime
|
35
41
|
prerelease: false
|
36
42
|
version_requirements: !ruby/object:Gem::Requirement
|
37
43
|
requirements:
|
38
|
-
- -
|
44
|
+
- - ">="
|
39
45
|
- !ruby/object:Gem::Version
|
40
46
|
version: 0.3.5
|
41
47
|
- !ruby/object:Gem::Dependency
|
42
48
|
name: open-uri-cached
|
43
49
|
requirement: !ruby/object:Gem::Requirement
|
44
50
|
requirements:
|
45
|
-
- -
|
51
|
+
- - ">="
|
46
52
|
- !ruby/object:Gem::Version
|
47
53
|
version: 0.0.5
|
48
54
|
type: :development
|
49
55
|
prerelease: false
|
50
56
|
version_requirements: !ruby/object:Gem::Requirement
|
51
57
|
requirements:
|
52
|
-
- -
|
58
|
+
- - ">="
|
53
59
|
- !ruby/object:Gem::Version
|
54
60
|
version: 0.0.5
|
55
61
|
- !ruby/object:Gem::Dependency
|
56
62
|
name: rspec
|
57
63
|
requirement: !ruby/object:Gem::Requirement
|
58
64
|
requirements:
|
59
|
-
- -
|
65
|
+
- - "~>"
|
60
66
|
- !ruby/object:Gem::Version
|
61
|
-
version: 2.
|
67
|
+
version: '2.14'
|
62
68
|
type: :development
|
63
69
|
prerelease: false
|
64
70
|
version_requirements: !ruby/object:Gem::Requirement
|
65
71
|
requirements:
|
66
|
-
- -
|
72
|
+
- - "~>"
|
67
73
|
- !ruby/object:Gem::Version
|
68
|
-
version: 2.
|
74
|
+
version: '2.14'
|
69
75
|
- !ruby/object:Gem::Dependency
|
70
76
|
name: rdf-isomorphic
|
71
77
|
requirement: !ruby/object:Gem::Requirement
|
72
78
|
requirements:
|
73
|
-
- -
|
79
|
+
- - "~>"
|
74
80
|
- !ruby/object:Gem::Version
|
75
81
|
version: '1.1'
|
76
82
|
type: :development
|
77
83
|
prerelease: false
|
78
84
|
version_requirements: !ruby/object:Gem::Requirement
|
79
85
|
requirements:
|
80
|
-
- -
|
86
|
+
- - "~>"
|
81
87
|
- !ruby/object:Gem::Version
|
82
88
|
version: '1.1'
|
83
89
|
- !ruby/object:Gem::Dependency
|
84
90
|
name: json-ld
|
85
91
|
requirement: !ruby/object:Gem::Requirement
|
86
92
|
requirements:
|
87
|
-
- -
|
93
|
+
- - "~>"
|
88
94
|
- !ruby/object:Gem::Version
|
89
95
|
version: '1.1'
|
90
96
|
type: :development
|
91
97
|
prerelease: false
|
92
98
|
version_requirements: !ruby/object:Gem::Requirement
|
93
99
|
requirements:
|
94
|
-
- -
|
100
|
+
- - "~>"
|
95
101
|
- !ruby/object:Gem::Version
|
96
102
|
version: '1.1'
|
97
103
|
- !ruby/object:Gem::Dependency
|
98
104
|
name: yard
|
99
105
|
requirement: !ruby/object:Gem::Requirement
|
100
106
|
requirements:
|
101
|
-
- -
|
107
|
+
- - ">="
|
102
108
|
- !ruby/object:Gem::Version
|
103
|
-
version: 0.8.
|
109
|
+
version: 0.8.7
|
104
110
|
type: :development
|
105
111
|
prerelease: false
|
106
112
|
version_requirements: !ruby/object:Gem::Requirement
|
107
113
|
requirements:
|
108
|
-
- -
|
114
|
+
- - ">="
|
109
115
|
- !ruby/object:Gem::Version
|
110
|
-
version: 0.8.
|
116
|
+
version: 0.8.7
|
111
117
|
- !ruby/object:Gem::Dependency
|
112
118
|
name: rdf-spec
|
113
119
|
requirement: !ruby/object:Gem::Requirement
|
114
120
|
requirements:
|
115
|
-
- -
|
121
|
+
- - "~>"
|
116
122
|
- !ruby/object:Gem::Version
|
117
123
|
version: '1.1'
|
118
124
|
type: :development
|
119
125
|
prerelease: false
|
120
126
|
version_requirements: !ruby/object:Gem::Requirement
|
121
127
|
requirements:
|
122
|
-
- -
|
128
|
+
- - "~>"
|
123
129
|
- !ruby/object:Gem::Version
|
124
130
|
version: '1.1'
|
125
131
|
- !ruby/object:Gem::Dependency
|
126
132
|
name: rake
|
127
133
|
requirement: !ruby/object:Gem::Requirement
|
128
134
|
requirements:
|
129
|
-
- -
|
135
|
+
- - ">="
|
130
136
|
- !ruby/object:Gem::Version
|
131
137
|
version: '0'
|
132
138
|
type: :development
|
133
139
|
prerelease: false
|
134
140
|
version_requirements: !ruby/object:Gem::Requirement
|
135
141
|
requirements:
|
136
|
-
- -
|
142
|
+
- - ">="
|
137
143
|
- !ruby/object:Gem::Version
|
138
144
|
version: '0'
|
139
145
|
description: RDF::Turtle is an Turtle reader/writer for the RDF.rb library suite.
|
@@ -143,10 +149,11 @@ extensions: []
|
|
143
149
|
extra_rdoc_files: []
|
144
150
|
files:
|
145
151
|
- AUTHORS
|
146
|
-
- README.md
|
147
152
|
- History
|
153
|
+
- README.md
|
148
154
|
- UNLICENSE
|
149
155
|
- VERSION
|
156
|
+
- lib/rdf/turtle.rb
|
150
157
|
- lib/rdf/turtle/format.rb
|
151
158
|
- lib/rdf/turtle/freebase_reader.rb
|
152
159
|
- lib/rdf/turtle/meta.rb
|
@@ -155,7 +162,6 @@ files:
|
|
155
162
|
- lib/rdf/turtle/terminals.rb
|
156
163
|
- lib/rdf/turtle/version.rb
|
157
164
|
- lib/rdf/turtle/writer.rb
|
158
|
-
- lib/rdf/turtle.rb
|
159
165
|
homepage: http://ruby-rdf.github.com/rdf-turtle
|
160
166
|
licenses:
|
161
167
|
- Public Domain
|
@@ -166,17 +172,17 @@ require_paths:
|
|
166
172
|
- lib
|
167
173
|
required_ruby_version: !ruby/object:Gem::Requirement
|
168
174
|
requirements:
|
169
|
-
- -
|
175
|
+
- - ">="
|
170
176
|
- !ruby/object:Gem::Version
|
171
177
|
version: 1.9.2
|
172
178
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
173
179
|
requirements:
|
174
|
-
- -
|
180
|
+
- - ">="
|
175
181
|
- !ruby/object:Gem::Version
|
176
182
|
version: '0'
|
177
183
|
requirements: []
|
178
184
|
rubyforge_project: rdf-turtle
|
179
|
-
rubygems_version: 2.
|
185
|
+
rubygems_version: 2.2.2
|
180
186
|
signing_key:
|
181
187
|
specification_version: 4
|
182
188
|
summary: Turtle reader/writer for Ruby.
|