rdf-n3 0.3.3 → 0.3.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.md +4 -0
- data/VERSION +1 -1
- data/example-files/best-buy.nt +4 -0
- data/lib/rdf/n3/writer.rb +20 -19
- data/rdf-n3.gemspec +4 -3
- data/script/parse +1 -1
- metadata +52 -3
data/History.md
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.3
|
1
|
+
0.3.3.1
|
@@ -0,0 +1,4 @@
|
|
1
|
+
<http://www.bestbuy.com/shop/thermometers> <http://www.w3.org/1999/xhtml/vocab#stylesheet> <http://images.bestbuy.com:80/BestBuy_US/en_US/images/global/mobile/js/thickbox/thickbox.css> .
|
2
|
+
<http://www.bestbuy.com/shop/thermometers> <http://www.w3.org/1999/xhtml/vocab#stylesheet> <http://images.bestbuy.com:80/BestBuy_US/store/styles/global-min.css> .
|
3
|
+
<http://images.bestbuy.com:80/BestBuy_US/store/styles/global-min.css> <http://www.w3.org/1999/xhtml/vocab#stylesheet> <http://images.bestbuy.com:80/BestBuy_US/store/styles/atmosphere-min.css> .
|
4
|
+
<http://images.bestbuy.com:80/BestBuy_US/store/styles/atmosphere-min.css> <http://www.w3.org/1999/xhtml/vocab#stylesheet> <http://images.bestbuy.com:80/BestBuy_US/store/styles/list-2-0-min.css> .
|
data/lib/rdf/n3/writer.rb
CHANGED
@@ -136,7 +136,7 @@ module RDF::N3
|
|
136
136
|
# @see #write_triple
|
137
137
|
def write_epilogue
|
138
138
|
@max_depth = @options[:max_depth] || 3
|
139
|
-
@base_uri = @options[:base_uri]
|
139
|
+
@base_uri = RDF::URI(@options[:base_uri])
|
140
140
|
@debug = @options[:debug]
|
141
141
|
|
142
142
|
self.reset
|
@@ -147,7 +147,6 @@ module RDF::N3
|
|
147
147
|
start_document
|
148
148
|
|
149
149
|
order_subjects.each do |subject|
|
150
|
-
#STDERR.puts "subj: #{subject.inspect}"
|
151
150
|
unless is_done?(subject)
|
152
151
|
statement(subject)
|
153
152
|
end
|
@@ -252,7 +251,8 @@ module RDF::N3
|
|
252
251
|
# @return [String]
|
253
252
|
def format_uri(uri, options = {})
|
254
253
|
md = relativize(uri)
|
255
|
-
|
254
|
+
add_debug("relativize(#{uri.inspect}) => #{md.inspect}") if md != uri.to_s
|
255
|
+
md != uri.to_s ? "<#{md}>" : (get_qname(uri) || "<#{uri}>")
|
256
256
|
end
|
257
257
|
|
258
258
|
##
|
@@ -306,13 +306,13 @@ module RDF::N3
|
|
306
306
|
# Start with base_uri
|
307
307
|
if base_uri && @subjects.keys.include?(base_uri)
|
308
308
|
subjects << base_uri
|
309
|
-
seen[
|
309
|
+
seen[base_uri] = true
|
310
310
|
end
|
311
311
|
|
312
312
|
# Add distinguished classes
|
313
313
|
top_classes.each do |class_uri|
|
314
314
|
graph.query(:predicate => RDF.type, :object => class_uri).map {|st| st.subject}.sort.uniq.each do |subject|
|
315
|
-
|
315
|
+
add_debug "order_subjects: #{subject.inspect}"
|
316
316
|
subjects << subject
|
317
317
|
seen[subject] = true
|
318
318
|
end
|
@@ -409,23 +409,23 @@ module RDF::N3
|
|
409
409
|
# Checks if l is a valid RDF list, i.e. no nodes have other properties.
|
410
410
|
def is_valid_list(l)
|
411
411
|
props = @graph.properties(l)
|
412
|
-
#
|
412
|
+
#add_debug "is_valid_list: #{props.inspect}"
|
413
413
|
return false unless props.has_key?(RDF.first.to_s) || l == RDF.nil
|
414
414
|
while l && l != RDF.nil do
|
415
|
-
#
|
415
|
+
#add_debug "is_valid_list(length): #{props.length}"
|
416
416
|
return false unless props.has_key?(RDF.first.to_s) && props.has_key?(RDF.rest.to_s)
|
417
417
|
n = props[RDF.rest.to_s]
|
418
|
-
#
|
418
|
+
#add_debug "is_valid_list(n): #{n.inspect}"
|
419
419
|
return false unless n.is_a?(Array) && n.length == 1
|
420
420
|
l = n.first
|
421
421
|
props = @graph.properties(l)
|
422
422
|
end
|
423
|
-
#
|
423
|
+
#add_debug "is_valid_list: valid"
|
424
424
|
true
|
425
425
|
end
|
426
426
|
|
427
427
|
def do_list(l)
|
428
|
-
|
428
|
+
add_debug "do_list: #{l.inspect}"
|
429
429
|
position = :subject
|
430
430
|
while l do
|
431
431
|
p = @graph.properties(l)
|
@@ -441,7 +441,7 @@ module RDF::N3
|
|
441
441
|
|
442
442
|
def p_list(node, position)
|
443
443
|
return false if !is_valid_list(node)
|
444
|
-
#
|
444
|
+
#add_debug "p_list: #{node.inspect}, #{position}"
|
445
445
|
|
446
446
|
@output.write(position == :subject ? "(" : " (")
|
447
447
|
@depth += 2
|
@@ -459,7 +459,7 @@ module RDF::N3
|
|
459
459
|
def p_squared(node, position)
|
460
460
|
return false unless p_squared?(node, position)
|
461
461
|
|
462
|
-
#
|
462
|
+
#add_debug "p_squared: #{node.inspect}, #{position}"
|
463
463
|
subject_done(node)
|
464
464
|
@output.write(position == :subject ? '[' : ' [')
|
465
465
|
@depth += 2
|
@@ -471,18 +471,18 @@ module RDF::N3
|
|
471
471
|
end
|
472
472
|
|
473
473
|
def p_default(node, position)
|
474
|
-
#
|
474
|
+
#add_debug "p_default: #{node.inspect}, #{position}"
|
475
475
|
l = (position == :subject ? "" : " ") + format_value(node)
|
476
476
|
@output.write(l)
|
477
477
|
end
|
478
478
|
|
479
479
|
def path(node, position)
|
480
|
-
|
480
|
+
add_debug "path: #{node.inspect}, pos: #{position}, []: #{is_valid_list(node)}, p2?: #{p_squared?(node, position)}, rc: #{ref_count(node)}"
|
481
481
|
raise RDF::WriterError, "Cannot serialize node '#{node}'" unless p_list(node, position) || p_squared(node, position) || p_default(node, position)
|
482
482
|
end
|
483
483
|
|
484
484
|
def verb(node)
|
485
|
-
|
485
|
+
add_debug "verb: #{node.inspect}"
|
486
486
|
if node == RDF.type
|
487
487
|
@output.write(" a")
|
488
488
|
else
|
@@ -491,7 +491,7 @@ module RDF::N3
|
|
491
491
|
end
|
492
492
|
|
493
493
|
def object_list(objects)
|
494
|
-
|
494
|
+
add_debug "object_list: #{objects.inspect}"
|
495
495
|
return if objects.empty?
|
496
496
|
|
497
497
|
objects.each_with_index do |obj, i|
|
@@ -503,7 +503,7 @@ module RDF::N3
|
|
503
503
|
def predicate_list(subject)
|
504
504
|
properties = @graph.properties(subject)
|
505
505
|
prop_list = sort_properties(properties) - [RDF.first.to_s, RDF.rest.to_s]
|
506
|
-
|
506
|
+
add_debug "predicate_list: #{prop_list.inspect}"
|
507
507
|
return if prop_list.empty?
|
508
508
|
|
509
509
|
prop_list.each_with_index do |prop, i|
|
@@ -513,7 +513,7 @@ module RDF::N3
|
|
513
513
|
verb(prop[0, 2] == "_:" ? RDF::Node.new(prop.split(':').last) : RDF::URI.intern(prop))
|
514
514
|
object_list(properties[prop])
|
515
515
|
rescue Addressable::URI::InvalidURIError => e
|
516
|
-
|
516
|
+
add_debug "Predicate #{prop.inspect} is an invalid URI: #{e.message}"
|
517
517
|
end
|
518
518
|
end
|
519
519
|
end
|
@@ -525,6 +525,7 @@ module RDF::N3
|
|
525
525
|
def s_squared(subject)
|
526
526
|
return false unless s_squared?(subject)
|
527
527
|
|
528
|
+
add_debug "s_squared: #{subject.inspect}"
|
528
529
|
@output.write("\n#{indent} [")
|
529
530
|
@depth += 1
|
530
531
|
predicate_list(subject)
|
@@ -542,7 +543,7 @@ module RDF::N3
|
|
542
543
|
end
|
543
544
|
|
544
545
|
def statement(subject)
|
545
|
-
|
546
|
+
add_debug "statement: #{subject.inspect}, s2?: #{s_squared?(subject)}"
|
546
547
|
subject_done(subject)
|
547
548
|
s_squared(subject) || s_default(subject)
|
548
549
|
end
|
data/rdf-n3.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{rdf-n3}
|
8
|
-
s.version = "0.3.3"
|
8
|
+
s.version = "0.3.3.1"
|
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{2011-04-
|
12
|
+
s.date = %q{2011-04-26}
|
13
13
|
s.description = %q{RDF::N3 is an Notation-3 and Turtle reader/writer for the RDF.rb library suite.}
|
14
14
|
s.email = %q{gregg@kellogg-assoc.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -30,6 +30,7 @@ Gem::Specification.new do |s|
|
|
30
30
|
"VERSION",
|
31
31
|
"example-files/arnau-registered-vocab.rb",
|
32
32
|
"example-files/arnau-stack-overflow.ttl",
|
33
|
+
"example-files/best-buy.nt",
|
33
34
|
"example-files/dwbutler-mj.n3",
|
34
35
|
"example-files/dwbutler-mj.ttl",
|
35
36
|
"example-files/lee-reilly-list.rb",
|
@@ -70,7 +71,7 @@ Gem::Specification.new do |s|
|
|
70
71
|
]
|
71
72
|
s.homepage = %q{http://github.com/gkellogg/rdf-n3}
|
72
73
|
s.require_paths = ["lib"]
|
73
|
-
s.rubygems_version = %q{1.
|
74
|
+
s.rubygems_version = %q{1.5.0}
|
74
75
|
s.summary = %q{N3/Turtle reader/writer for RDF.rb.}
|
75
76
|
s.test_files = [
|
76
77
|
"spec/cwm_spec.rb",
|
data/script/parse
CHANGED
@@ -46,7 +46,7 @@ def run(input, options)
|
|
46
46
|
r = reader_class.new(input, :base_uri => options[:base_uri], :strict => true)
|
47
47
|
g = RDF::Graph.new << r
|
48
48
|
num = g.count
|
49
|
-
options[:output].puts g.dump(options[:output_format], :base_uri =>
|
49
|
+
options[:output].puts g.dump(options[:output_format], :base_uri => options[:base_uri], :prefixes => r.prefixes)
|
50
50
|
end
|
51
51
|
puts
|
52
52
|
secs = Time.new - start
|
metadata
CHANGED
@@ -1,8 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rdf-n3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 89
|
4
5
|
prerelease:
|
5
|
-
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 3
|
9
|
+
- 3
|
10
|
+
- 1
|
11
|
+
version: 0.3.3.1
|
6
12
|
platform: ruby
|
7
13
|
authors:
|
8
14
|
- Gregg Kellogg
|
@@ -10,7 +16,7 @@ autorequire:
|
|
10
16
|
bindir: bin
|
11
17
|
cert_chain: []
|
12
18
|
|
13
|
-
date: 2011-04-
|
19
|
+
date: 2011-04-26 00:00:00 -07:00
|
14
20
|
default_executable:
|
15
21
|
dependencies:
|
16
22
|
- !ruby/object:Gem::Dependency
|
@@ -21,6 +27,11 @@ dependencies:
|
|
21
27
|
requirements:
|
22
28
|
- - ">="
|
23
29
|
- !ruby/object:Gem::Version
|
30
|
+
hash: 21
|
31
|
+
segments:
|
32
|
+
- 0
|
33
|
+
- 3
|
34
|
+
- 3
|
24
35
|
version: 0.3.3
|
25
36
|
type: :runtime
|
26
37
|
version_requirements: *id001
|
@@ -32,6 +43,9 @@ dependencies:
|
|
32
43
|
requirements:
|
33
44
|
- - ">="
|
34
45
|
- !ruby/object:Gem::Version
|
46
|
+
hash: 3
|
47
|
+
segments:
|
48
|
+
- 0
|
35
49
|
version: "0"
|
36
50
|
type: :development
|
37
51
|
version_requirements: *id002
|
@@ -43,6 +57,11 @@ dependencies:
|
|
43
57
|
requirements:
|
44
58
|
- - ">="
|
45
59
|
- !ruby/object:Gem::Version
|
60
|
+
hash: 7
|
61
|
+
segments:
|
62
|
+
- 0
|
63
|
+
- 0
|
64
|
+
- 12
|
46
65
|
version: 0.0.12
|
47
66
|
type: :development
|
48
67
|
version_requirements: *id003
|
@@ -54,6 +73,11 @@ dependencies:
|
|
54
73
|
requirements:
|
55
74
|
- - ">="
|
56
75
|
- !ruby/object:Gem::Version
|
76
|
+
hash: 27
|
77
|
+
segments:
|
78
|
+
- 2
|
79
|
+
- 5
|
80
|
+
- 0
|
57
81
|
version: 2.5.0
|
58
82
|
type: :development
|
59
83
|
version_requirements: *id004
|
@@ -65,6 +89,11 @@ dependencies:
|
|
65
89
|
requirements:
|
66
90
|
- - ">="
|
67
91
|
- !ruby/object:Gem::Version
|
92
|
+
hash: 21
|
93
|
+
segments:
|
94
|
+
- 0
|
95
|
+
- 3
|
96
|
+
- 3
|
68
97
|
version: 0.3.3
|
69
98
|
type: :development
|
70
99
|
version_requirements: *id005
|
@@ -76,6 +105,11 @@ dependencies:
|
|
76
105
|
requirements:
|
77
106
|
- - ">="
|
78
107
|
- !ruby/object:Gem::Version
|
108
|
+
hash: 21
|
109
|
+
segments:
|
110
|
+
- 0
|
111
|
+
- 3
|
112
|
+
- 3
|
79
113
|
version: 0.3.3
|
80
114
|
type: :development
|
81
115
|
version_requirements: *id006
|
@@ -87,6 +121,11 @@ dependencies:
|
|
87
121
|
requirements:
|
88
122
|
- - ">="
|
89
123
|
- !ruby/object:Gem::Version
|
124
|
+
hash: 27
|
125
|
+
segments:
|
126
|
+
- 0
|
127
|
+
- 3
|
128
|
+
- 4
|
90
129
|
version: 0.3.4
|
91
130
|
type: :development
|
92
131
|
version_requirements: *id007
|
@@ -98,6 +137,9 @@ dependencies:
|
|
98
137
|
requirements:
|
99
138
|
- - ">="
|
100
139
|
- !ruby/object:Gem::Version
|
140
|
+
hash: 3
|
141
|
+
segments:
|
142
|
+
- 0
|
101
143
|
version: "0"
|
102
144
|
type: :development
|
103
145
|
version_requirements: *id008
|
@@ -124,6 +166,7 @@ files:
|
|
124
166
|
- VERSION
|
125
167
|
- example-files/arnau-registered-vocab.rb
|
126
168
|
- example-files/arnau-stack-overflow.ttl
|
169
|
+
- example-files/best-buy.nt
|
127
170
|
- example-files/dwbutler-mj.n3
|
128
171
|
- example-files/dwbutler-mj.ttl
|
129
172
|
- example-files/lee-reilly-list.rb
|
@@ -175,17 +218,23 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
175
218
|
requirements:
|
176
219
|
- - ">="
|
177
220
|
- !ruby/object:Gem::Version
|
221
|
+
hash: 3
|
222
|
+
segments:
|
223
|
+
- 0
|
178
224
|
version: "0"
|
179
225
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
180
226
|
none: false
|
181
227
|
requirements:
|
182
228
|
- - ">="
|
183
229
|
- !ruby/object:Gem::Version
|
230
|
+
hash: 3
|
231
|
+
segments:
|
232
|
+
- 0
|
184
233
|
version: "0"
|
185
234
|
requirements: []
|
186
235
|
|
187
236
|
rubyforge_project:
|
188
|
-
rubygems_version: 1.
|
237
|
+
rubygems_version: 1.5.0
|
189
238
|
signing_key:
|
190
239
|
specification_version: 3
|
191
240
|
summary: N3/Turtle reader/writer for RDF.rb.
|