params-registry 0.1.8 → 0.1.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/params/registry/instance.rb +5 -0
- data/lib/params/registry/template.rb +2 -2
- data/lib/params/registry/types.rb +7 -4
- data/lib/params/registry/version.rb +1 -1
- data/lib/params/registry.rb +28 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ecda0bf7bd68a9dd7fd9b04cf9d5e3a2695aea9ac1d855f52dabff25f3992af3
|
4
|
+
data.tar.gz: 0acfd9a1a99e2be5f61f85c0b8fad2bdde2e2db9b04060d3ead7d810a508827d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f095e9e830b31e7c546cecde3dde1dc9112c4b65d82fa623c403fb5c0672cfeb1ebf0596582139c966b8cd5b23a9dbb23955c2d02100e56fd7e582b68006a36
|
7
|
+
data.tar.gz: fc4a9ce7dea830a031553473d7088951b1f10a16772b561ac10259dea87669ac4ce20caff03490a27a4709ab6bf1ad0ca88a82a8e92d17b13655d55e0ab9fd24
|
@@ -79,6 +79,7 @@ class Params::Registry::Instance
|
|
79
79
|
# canonicalize the keys of the struct
|
80
80
|
struct = Types::Input[struct].reduce({}) do |hash, pair|
|
81
81
|
key, value = pair
|
82
|
+
# warn "kv: #{key.inspect} => #{value.inspect}"
|
82
83
|
if t = @registry[@group][key]
|
83
84
|
# warn "yep #{key.inspect}"
|
84
85
|
hash[t.id] = value
|
@@ -198,6 +199,10 @@ class Params::Registry::Instance
|
|
198
199
|
out
|
199
200
|
end
|
200
201
|
|
202
|
+
def inspect
|
203
|
+
"<#{self.class} content: #{@content.inspect}, extra: #{@extra.inspect}>"
|
204
|
+
end
|
205
|
+
|
201
206
|
# # Retrieve an {Params::Registry::Instance} that isolates the
|
202
207
|
# # intersection of one or more groups
|
203
208
|
# #
|
@@ -189,7 +189,7 @@ class Params::Registry::Template
|
|
189
189
|
# valid values are drawn.
|
190
190
|
# @return [Object, nil]
|
191
191
|
def universe
|
192
|
-
refresh!
|
192
|
+
refresh! if @unifunc and not @universe
|
193
193
|
@universe
|
194
194
|
end
|
195
195
|
|
@@ -403,7 +403,7 @@ class Params::Registry::Template
|
|
403
403
|
@universe = univ
|
404
404
|
end
|
405
405
|
|
406
|
-
|
406
|
+
self
|
407
407
|
end
|
408
408
|
|
409
409
|
# Return a suitable representation for debugging.
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative
|
3
|
+
require_relative 'version'
|
4
4
|
|
5
5
|
require 'dry-types' # let's try to use this and not hate it
|
6
6
|
require 'set' # for some reason Set is not in the kernel but Range is
|
@@ -122,9 +122,7 @@ module Params::Registry::Types
|
|
122
122
|
end
|
123
123
|
|
124
124
|
# And {::DateTime}
|
125
|
-
DateTime = self.Constructor(::DateTime)
|
126
|
-
::DateTime.parse x
|
127
|
-
end
|
125
|
+
DateTime = self.Constructor(::DateTime) { |x| ::DateTime.parse x }
|
128
126
|
|
129
127
|
# Aaand {::Time}
|
130
128
|
Time = self.Constructor(::Time) do |x|
|
@@ -137,6 +135,10 @@ module Params::Registry::Types
|
|
137
135
|
|
138
136
|
# @!group Composite types not already defined
|
139
137
|
|
138
|
+
List = self.Constructor(::Array) do |x|
|
139
|
+
x.respond_to?(:to_a) ? x.to_a : [x]
|
140
|
+
end
|
141
|
+
|
140
142
|
# {::Set}
|
141
143
|
Set = self.Constructor(::Set) { |x| ::Set[*x] }
|
142
144
|
|
@@ -157,6 +159,7 @@ module Params::Registry::Types
|
|
157
159
|
|
158
160
|
Input = self.Constructor(::Hash) do |input|
|
159
161
|
input = input.query.to_s if input.is_a? ::URI
|
162
|
+
input = '' if input.nil?
|
160
163
|
input = ::URI.decode_www_form input if input.is_a? ::String
|
161
164
|
|
162
165
|
case input
|
data/lib/params/registry.rb
CHANGED
@@ -135,6 +135,31 @@ class Params::Registry
|
|
135
135
|
#
|
136
136
|
def templates ; @templates.values; end
|
137
137
|
|
138
|
+
# Assign a new sequence of templates to the group.
|
139
|
+
#
|
140
|
+
# @param templates [Array, Hash]
|
141
|
+
#
|
142
|
+
# @return [Array, Hash] whatever was passed
|
143
|
+
# in because Ruby ignores the output
|
144
|
+
#
|
145
|
+
def templates= templates
|
146
|
+
templates = templates.to_a if templates.is_a? Hash
|
147
|
+
|
148
|
+
raise ArgumentError,
|
149
|
+
"Don't know what to do with #{templates.class}" unless
|
150
|
+
templates.respond_to? :to_a
|
151
|
+
|
152
|
+
# empty out the actual instance member
|
153
|
+
@templates.clear
|
154
|
+
|
155
|
+
# this should destructure appropriately (XXX MAYBE???) and also
|
156
|
+
# use the overloaded subscript assignment method
|
157
|
+
templates.to_a.each { |id, spec| self[id] = spec || id }
|
158
|
+
|
159
|
+
# now return the new members
|
160
|
+
@templates.values
|
161
|
+
end
|
162
|
+
|
138
163
|
# Return the canonical identifier for the template.
|
139
164
|
#
|
140
165
|
# @param id [Object] the identifier, canonical or otherwise.
|
@@ -381,11 +406,12 @@ class Params::Registry
|
|
381
406
|
|
382
407
|
# Refresh any stateful elements of the templates.
|
383
408
|
#
|
384
|
-
# @return [
|
409
|
+
# @return [self]
|
385
410
|
#
|
386
411
|
def refresh!
|
387
412
|
templates.each { |t| t.refresh! }
|
388
|
-
|
413
|
+
|
414
|
+
self
|
389
415
|
end
|
390
416
|
|
391
417
|
# @!group Quasi-static methods to override in subclasses
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: params-registry
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.12
|
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-01-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-types
|
@@ -69,7 +69,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
69
69
|
- !ruby/object:Gem::Version
|
70
70
|
version: '0'
|
71
71
|
requirements: []
|
72
|
-
rubygems_version: 3.
|
72
|
+
rubygems_version: 3.4.20
|
73
73
|
signing_key:
|
74
74
|
specification_version: 4
|
75
75
|
summary: 'Params::Registry: a registry for URI query parameters'
|