rdf 3.1.2 → 3.1.3

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: 39ba8235c527933f06e9685428f3948547e46563c68ca5d0e1f3ac22f12b3d60
4
- data.tar.gz: 00fb02e10e11e2e011c58766c609ca186dc1e2c74ef44f09af704297681e94b8
3
+ metadata.gz: 3edf1c89289474f1f14ee840b6cd5903c6443afd7ad8121e3ddfce5bcae30895
4
+ data.tar.gz: 12497c16ebc49b1bcfaa404609389b8c98cea22233868ff1378a810ede686371
5
5
  SHA512:
6
- metadata.gz: 46e0b83df6bf5fbdecdee12cc9bb2e34f93dce625a1a86edbd3251366a6ac6ef09fa4a1520c883c0f7a0a5d2bdb492e97fddeed739b4db28e6e69e278cc78e33
7
- data.tar.gz: db8b82296da844a5b8c0ab8547038cdd4f96e41231db41f2f8f0abd2d04859918a90adee3ded6369c9a37f20c192e16cc9d656910661533bb3bbbf5fb46a6aa5
6
+ metadata.gz: de42189a4269854a6292b4cd0b0de0a07c0a0d0e5b61a40cc9b4f460b66ada2f090fbadb0486e48d183f366ce776ea88ff89f715f61439c8c5ad7857d24047cb
7
+ data.tar.gz: 20725ce63013fed6385e9e1aade5b808d821de4ef5986cedbf9b87c34cc9f749b132437e2b7e496da12774214b709d6d3accf9b0861c14fa3353452ca5e0cbf5
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.1.2
1
+ 3.1.3
@@ -218,5 +218,12 @@ module RDF
218
218
  stmts.each { |s| send(target) << s }
219
219
  end
220
220
 
221
+ # This simply returns its argument as a query in order to trick
222
+ # {RDF::Mutable#delete} into working.
223
+ def query(stmt)
224
+ RDF::Query.new RDF::Query::Pattern.from(stmt)
225
+ end
226
+
227
+ undef_method :load
221
228
  end # Changeset
222
229
  end # RDF
@@ -85,10 +85,15 @@ module RDF
85
85
  end
86
86
 
87
87
  ##
88
- # A hash of all vocabularies by prefix showing relevant URI and associated vocabulary Class Name
88
+ # A hash of all vocabularies by prefix showing relevant URI and
89
+ # associated vocabulary Class Name
90
+ #
89
91
  # @return [Hash{Symbol => Hash{Symbol => String}}]
90
92
  def vocab_map
91
- VOCABS
93
+ # Create an initial duplicate of RDF::VOCABS. We want to
94
+ # ensure the hash itself is modifiable but the values are
95
+ # frozen.
96
+ @vocab_map ||= RDF::VOCABS.transform_values(&:freeze)
92
97
  end
93
98
 
94
99
  ##
@@ -100,6 +105,36 @@ module RDF
100
105
  RDF.const_get(sym.to_sym)
101
106
  end
102
107
 
108
+ ##
109
+ # Register a vocabulary for internal prefix lookups. Parameters
110
+ # of interest include `:uri`, `:class_name`, `:source`, and `:skip`.
111
+ #
112
+ # @param prefix [Symbol] the prefix to use
113
+ # @param vocab [String, Class] either the URI or the vocab class
114
+ # @param params [Hash{Symbol => String}] Relevant parameters
115
+ # @return [Hash] The parameter hash, but frozen
116
+ def register(prefix, vocab, **params)
117
+ # check the input
118
+ raise ArgumentError, "#{prefix} must be symbol-able" unless
119
+ [String, Symbol].any? { |c| prefix.is_a? c }
120
+
121
+ # note an explicit uri: param overrides
122
+ case vocab
123
+ when String then params[:uri] ||= vocab
124
+ when Class
125
+ raise ArgumentError, 'vocab must be an RDF::(Strict)Vocabulary' unless
126
+ vocab.ancestors.include? RDF::Vocabulary
127
+ params[:class] = vocab
128
+ params[:uri] ||= vocab.to_uri.to_s
129
+ end
130
+
131
+ # fill in the class name
132
+ params[:class_name] ||= prefix.to_s.upcase
133
+
134
+ # now freeze and assign
135
+ vocab_map[prefix.to_s.to_sym] = params.freeze
136
+ end
137
+
103
138
  ##
104
139
  # Limits iteration over vocabularies to just those selected
105
140
  #
@@ -347,7 +382,8 @@ module RDF
347
382
  if prefix == "rdf"
348
383
  RDF[suffix]
349
384
  elsif vocab_detail = RDF::Vocabulary.vocab_map[prefix.to_sym]
350
- vocab = RDF::Vocabulary.from_sym(vocab_detail[:class_name])
385
+ vocab = vocab_detail[:class] ||
386
+ RDF::Vocabulary.from_sym(vocab_detail[:class_name])
351
387
  suffix.to_s.empty? ? vocab.to_uri : vocab[suffix]
352
388
  else
353
389
  (RDF::Vocabulary.find_term(pname) rescue nil) || RDF::URI(pname, validate: true)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rdf
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.2
4
+ version: 3.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arto Bendiken
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2020-05-30 00:00:00.000000000 Z
13
+ date: 2020-06-16 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: link_header