rdf-kv 0.1.3 → 0.1.5
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.
- checksums.yaml +4 -4
- data/lib/rdf/kv/version.rb +1 -1
- data/lib/rdf/kv.rb +26 -16
- data/rdf-kv.gemspec +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f175bc353d9957490f45693644270d8ce9d82392352fefa7e22534786ad5fc7
|
4
|
+
data.tar.gz: 2d795adc0b253f8644ec110c4c972af8af5439fa00268a5455211df4794e46b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a8a7542849b4d2f86fcbdf8bfe13da51deac88f436ad0238fc663e18e3afe3f9c547c774de45caa22d8e1f42ea7d54d05d0eacd740c2d07dd5dbac50361f4bf
|
7
|
+
data.tar.gz: 1bd0ec5aab7ab7dc88d8de63e09ebd05ddcdcd50ad20485336dcac25b14d85551565d39ef47d8915f0790cddf69b01cb06373a1b12d12a5db9d30036fa430940
|
data/lib/rdf/kv/version.rb
CHANGED
data/lib/rdf/kv.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'rdf/kv/version'
|
2
2
|
|
3
3
|
require 'rdf'
|
4
|
+
require 'time'
|
4
5
|
require 'uri'
|
5
6
|
require 'uuidtools'
|
6
7
|
require 'uuid-ncname'
|
@@ -56,6 +57,14 @@ class RDF::KV
|
|
56
57
|
UUID::NCName.to_ncname_64 UUIDTools::UUID.random_create.to_s, version: 1
|
57
58
|
end
|
58
59
|
|
60
|
+
# just the classics
|
61
|
+
DEFAULT_NS = {
|
62
|
+
rdf: RDF::RDFV,
|
63
|
+
rdfs: RDF::RDFS,
|
64
|
+
owl: RDF::OWL,
|
65
|
+
xsd: RDF::XSD,
|
66
|
+
}.freeze
|
67
|
+
|
59
68
|
# macros are initially represented as a pair: the macro value and a
|
60
69
|
# flag denoting whether or not the macro itself contains macros and to
|
61
70
|
# try to dereference it.
|
@@ -63,14 +72,7 @@ class RDF::KV
|
|
63
72
|
NEW_UUID: [[-> { UUIDTools::UUID.random_create.to_s }, false]],
|
64
73
|
NEW_UUID_URN: [[-> { UUIDTools::UUID.random_create.to_uri }, false]],
|
65
74
|
NEW_BNODE: [[-> { "_:#{random_uuid_ncname}" }, false]],
|
66
|
-
|
67
|
-
|
68
|
-
# just the classics
|
69
|
-
DEFAULT_NS = {
|
70
|
-
rdf: RDF::RDFV,
|
71
|
-
rdfs: RDF::RDFS,
|
72
|
-
owl: RDF::OWL,
|
73
|
-
xsd: RDF::XSD,
|
75
|
+
NEW_TIME_UTC: [[-> { Time.now.utc.iso8601 }, false]],
|
74
76
|
}.freeze
|
75
77
|
|
76
78
|
# Given a (massaged) set of macros, dereference the given array of
|
@@ -141,6 +143,8 @@ class RDF::KV
|
|
141
143
|
k = queue.shift
|
142
144
|
seen[k] = true
|
143
145
|
|
146
|
+
# warn "key: #{k}"
|
147
|
+
|
144
148
|
vals = macros[k]
|
145
149
|
|
146
150
|
# done and pending macros within the macros
|
@@ -152,18 +156,21 @@ class RDF::KV
|
|
152
156
|
|
153
157
|
next unless deref
|
154
158
|
|
159
|
+
# warn "pair: #{pair}"
|
160
|
+
|
161
|
+
# see a few lines below where deref is replaced
|
155
162
|
if deref.is_a? Array
|
156
163
|
deref.each { |m| done[m] ? dm[m] = true : pm[m] = true }
|
157
164
|
else
|
158
165
|
m = {}
|
159
|
-
val.scan(/#{MACRO}/o).compact.each do |x|
|
166
|
+
val.scan(/#{MACRO}/o).flatten.compact.each do |x|
|
160
167
|
x = x.to_sym
|
161
168
|
next unless macros[x]
|
162
169
|
raise "Self-reference found: #{x}" if x == k
|
163
170
|
|
164
171
|
m[x] = true
|
165
172
|
|
166
|
-
done[
|
173
|
+
done[x] ? dm[x] = true : pm[x] = true
|
167
174
|
end
|
168
175
|
|
169
176
|
# replace the deref flag with the elements to deref with
|
@@ -181,13 +188,16 @@ class RDF::KV
|
|
181
188
|
|
182
189
|
# put the current key back on the queue but put the dependencies first
|
183
190
|
queue = q + [k] + queue
|
191
|
+
warn "queue: #{queue}"
|
184
192
|
next
|
185
193
|
end
|
186
194
|
|
187
|
-
|
188
|
-
|
189
|
-
|
195
|
+
# warn vals.inspect
|
196
|
+
|
197
|
+
if dm.empty?
|
190
198
|
done[k] = vals.map(&:first)
|
199
|
+
else
|
200
|
+
done[k] = deref_content vals.map(&:first), done
|
191
201
|
end
|
192
202
|
|
193
203
|
# remember to remove this guy or we'll loop forever
|
@@ -270,7 +280,7 @@ class RDF::KV
|
|
270
280
|
graph.nil? or graph.is_a? RDF::Resource
|
271
281
|
raise ArgumentError, 'prefixes must be hashable' unless
|
272
282
|
prefixes.respond_to? :to_h
|
273
|
-
|
283
|
+
raise ArgumentError, 'callback must be callable' unless
|
274
284
|
callback.nil? or callback.respond_to? :call
|
275
285
|
|
276
286
|
@subject = subject
|
@@ -323,9 +333,9 @@ class RDF::KV
|
|
323
333
|
# step 2: dereference all the macros (that asked to be dereferenced)
|
324
334
|
begin
|
325
335
|
macros = massage_macros macros
|
326
|
-
rescue e
|
336
|
+
rescue Exception => e
|
327
337
|
# XXX we should do something more here
|
328
|
-
raise e
|
338
|
+
raise Error.new e
|
329
339
|
end
|
330
340
|
|
331
341
|
# step 3: apply special control macros (which modify self)
|
data/rdf-kv.gemspec
CHANGED
@@ -38,7 +38,7 @@ RDF::Changeset.
|
|
38
38
|
|
39
39
|
# stuff we use
|
40
40
|
spec.add_runtime_dependency 'rdf', '~> 3' # include my changes
|
41
|
-
spec.add_runtime_dependency 'uuidtools', '~>
|
41
|
+
spec.add_runtime_dependency 'uuidtools', '~> 3'
|
42
42
|
|
43
43
|
# stuff i wrote
|
44
44
|
spec.add_runtime_dependency 'uuid-ncname', '>= 0.4'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rdf-kv
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dorian Taylor
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-03-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -86,14 +86,14 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
89
|
+
version: '3'
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
96
|
+
version: '3'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: uuid-ncname
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -152,7 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
152
152
|
- !ruby/object:Gem::Version
|
153
153
|
version: '0'
|
154
154
|
requirements: []
|
155
|
-
rubygems_version: 3.
|
155
|
+
rubygems_version: 3.4.20
|
156
156
|
signing_key:
|
157
157
|
specification_version: 4
|
158
158
|
summary: Ruby implementation of the RDF-KV protocol
|