rdf-kv 0.1.1 → 0.1.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8ace8319f10ea7f736fc8881d6546b19c908284189e5a40f1d0e08659bad5b19
4
- data.tar.gz: f38dd9a9e778c037aad1199d6fc753bf6c037ba00acf0d6ee6e437e81efc0034
3
+ metadata.gz: 0ae8b165dd5ec6b9b0d5537be00fd9bdad78451db3a7d26004b83dc891e132f8
4
+ data.tar.gz: 2e66180337cd279075ef50978b175c04799d1e3d22206c6d12cc1cfc55c31a31
5
5
  SHA512:
6
- metadata.gz: efc28fc50193b33e5b461e053eff1e2eed46da55e29dd569b0546b0ef606f05b71dc36430eefed20031b35c25d5a2f455edcebda07f7fe327de7d43cf9373a68
7
- data.tar.gz: 053f381f9cf6d907183103f50e47ffd2e5a3f5f85c86b7017dfca0d7733b993cc5994e37feb4890183a8c9f3bbfe7dd5c63829fb9e0b39ccc63b25747c5bc3c4
6
+ metadata.gz: 46fe633378e76f51b004b26c6e3ceea96acedd4ab64dcc2e2801cd71c771cb4e879a9d13e87133fd9be6c2119423d2be04369954919f10dbc86bccaa72345063
7
+ data.tar.gz: b43fa6bf6d8106d67d016548c7313c41cebe883559fef3149c256727fb56a1f6af8646ec6064a5150115df560391db89ad65f940ddf38105f07202f13f4eb3c4
data/Gemfile CHANGED
@@ -2,6 +2,3 @@ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in rdf-kv.gemspec
4
4
  gemspec
5
-
6
- gem "rake", "~> 12.0"
7
- gem "rspec", "~> 3.0"
@@ -1,5 +1,5 @@
1
1
  module RDF
2
2
  class KV
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.4"
4
4
  end
5
5
  end
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'
@@ -52,15 +53,9 @@ class RDF::KV
52
53
  },
53
54
  }.freeze
54
55
 
55
- # macros are initially represented as a pair: the macro value and a
56
- # flag denoting whether or not the macro itself contains macros and to
57
- # try to dereference it.
58
- GENERATED = {
59
- NEW_UUID: [[-> { UUIDTools::UUID.random_create.to_s }, false]],
60
- NEW_UUID_URN: [[-> { UUIDTools::UUID.random_create.to_uri }, false]],
61
- NEW_BNODE: [[-> { "_:#{UUID::NCName.to_ncname_64(
62
- UUIDTools::UUID.random_create.to_s, version: 1) }" }, false]],
63
- }.freeze
56
+ def random_uuid_ncname
57
+ UUID::NCName.to_ncname_64 UUIDTools::UUID.random_create.to_s, version: 1
58
+ end
64
59
 
65
60
  # just the classics
66
61
  DEFAULT_NS = {
@@ -70,6 +65,16 @@ class RDF::KV
70
65
  xsd: RDF::XSD,
71
66
  }.freeze
72
67
 
68
+ # macros are initially represented as a pair: the macro value and a
69
+ # flag denoting whether or not the macro itself contains macros and to
70
+ # try to dereference it.
71
+ GENERATED = {
72
+ NEW_UUID: [[-> { UUIDTools::UUID.random_create.to_s }, false]],
73
+ NEW_UUID_URN: [[-> { UUIDTools::UUID.random_create.to_uri }, false]],
74
+ NEW_BNODE: [[-> { "_:#{random_uuid_ncname}" }, false]],
75
+ NEW_TIME_UTC: [[-> { Time.now.utc.iso8601 }, false]],
76
+ }.freeze
77
+
73
78
  # Given a (massaged) set of macros, dereference the given array of
74
79
  # strings and return it.
75
80
  def deref_content strings, macros
@@ -267,7 +272,7 @@ class RDF::KV
267
272
  graph.nil? or graph.is_a? RDF::Resource
268
273
  raise ArgumentError, 'prefixes must be hashable' unless
269
274
  prefixes.respond_to? :to_h
270
- rase ArgumentError, 'callback must be callable' unless
275
+ raise ArgumentError, 'callback must be callable' unless
271
276
  callback.nil? or callback.respond_to? :call
272
277
 
273
278
  @subject = subject
@@ -389,7 +394,10 @@ class RDF::KV
389
394
  o = contents[:term2] || subject
390
395
  else
391
396
  s, p = (contents[:term2] ? contents.values_at(:term1, :term2) :
392
- [subject, contents[:term1]]).map { |t| resolve_term t }
397
+ [subject, contents[:term1]]).map do |t|
398
+ t = resolve_term t
399
+ callback ? callback.call(t) : t
400
+ end
393
401
  end
394
402
 
395
403
  # the operation depends on whether the `-` modifier is present
@@ -399,9 +407,13 @@ class RDF::KV
399
407
  # string then we're deleting a wildcard, same if we `=` overwrite
400
408
  if !reverse and op == :delete && values.include?('') ||
401
409
  contents[:modifier][?=]
410
+
411
+ # create a random variable name so we don't pass in a nil
412
+ var = RDF::Query::Variable.new random_uuid_ncname
413
+
402
414
  # i can't remember why we don't do this in reverse, probably
403
415
  # because it is too easy to shoot yourself in the foot
404
- patch.delete RDF::Statement(s, p, nil, graph_name: g)
416
+ patch.delete RDF::Statement(s, p, var, graph_name: g)
405
417
 
406
418
  # nuke these since it will be pointless to evaluate further
407
419
  values.clear if op == :delete
data/rdf-kv.gemspec CHANGED
@@ -32,11 +32,13 @@ RDF::Changeset.
32
32
  spec.required_ruby_version = Gem::Requirement.new('>= 2.7')
33
33
  # dev/test dependencies
34
34
  spec.add_development_dependency 'bundler', '~> 2'
35
+ spec.add_development_dependency 'rake', '~> 13'
36
+ spec.add_development_dependency 'rspec', '~> 3'
35
37
  spec.add_development_dependency 'rdf-vocab', '~> 3'
36
38
 
37
39
  # stuff we use
38
40
  spec.add_runtime_dependency 'rdf', '~> 3' # include my changes
39
- spec.add_runtime_dependency 'uuidtools', '~> 2'
41
+ spec.add_runtime_dependency 'uuidtools', '~> 3'
40
42
 
41
43
  # stuff i wrote
42
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.1
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dorian Taylor
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-02-18 00:00:00.000000000 Z
11
+ date: 2025-03-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -24,6 +24,34 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '13'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '13'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3'
27
55
  - !ruby/object:Gem::Dependency
28
56
  name: rdf-vocab
29
57
  requirement: !ruby/object:Gem::Requirement
@@ -58,14 +86,14 @@ dependencies:
58
86
  requirements:
59
87
  - - "~>"
60
88
  - !ruby/object:Gem::Version
61
- version: '2'
89
+ version: '3'
62
90
  type: :runtime
63
91
  prerelease: false
64
92
  version_requirements: !ruby/object:Gem::Requirement
65
93
  requirements:
66
94
  - - "~>"
67
95
  - !ruby/object:Gem::Version
68
- version: '2'
96
+ version: '3'
69
97
  - !ruby/object:Gem::Dependency
70
98
  name: uuid-ncname
71
99
  requirement: !ruby/object:Gem::Requirement
@@ -124,7 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
124
152
  - !ruby/object:Gem::Version
125
153
  version: '0'
126
154
  requirements: []
127
- rubygems_version: 3.3.15
155
+ rubygems_version: 3.4.20
128
156
  signing_key:
129
157
  specification_version: 4
130
158
  summary: Ruby implementation of the RDF-KV protocol