params-registry 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a2c64c0a41224198bdd02db7960b2051e74726bf690ddc66b222bc077bdeafd0
4
- data.tar.gz: 5bd14e8bb789ea29ebca723e13edd08a51174b37aaa15fdec7829041025d471f
3
+ metadata.gz: a176c219561e992201c81af4cfa87b348fd408a5d52121ae9483004fdf073af3
4
+ data.tar.gz: 3d532a4041860f3c09df1c5802e3e4dc27931cd98e13b1a5355f9251a7c73f83
5
5
  SHA512:
6
- metadata.gz: 6f66092cfb1c2c047d6da054b295fa6dfd7796c9f01fe7543d9bfe680e5a57f0602fe48ae6f3733a8e65ea24fa29ad21ade20d18b90259a9784008f4e0876d7d
7
- data.tar.gz: e9a801b3893c7eb6a99eada97974750a1f78dd6a084202b0d7545b7464486770e062a4b138cf5466a242cf32f84a38990bc423261ea80ecf61e9e112b3858750
6
+ metadata.gz: 52eda8b9e02f1f82dd908a07d5c2f4f1179ec2a401dff5562b582f55bdc4989d11ae5956664784fc1dfcd58ccaa5d6899aa0d651794021f408e9c0e84c65c188
7
+ data.tar.gz: bf940c462597a0c43123e72f795e17f7778ff7ec2b73c7b9bcaea5c2e09b3a7472767342a12d4d155321c1033cf291571a0d91158745c6bae09af7f33f49ec4e
@@ -64,8 +64,8 @@ class Params::Registry::Instance
64
64
  #
65
65
  def initialize registry, struct, defaults: false, force: false
66
66
  if registry.is_a? Params::Registry::Group
67
- @group = registry
68
- @registry = registry.registry
67
+ @group = registry.id
68
+ @registry = registry = registry.registry
69
69
  else
70
70
  @group = nil
71
71
  @registry = registry
@@ -74,13 +74,17 @@ class Params::Registry::Instance
74
74
  @content = {}
75
75
  @extra = {}
76
76
 
77
+ warn "wtf lol #{@registry[@group].inspect}"
78
+
77
79
  # canonicalize the keys of the struct
78
80
  struct = Types::Input[struct].reduce({}) do |hash, pair|
79
81
  key, value = pair
80
- if t = registry[@group][key]
82
+ if t = @registry[@group][key]
83
+ warn "yep #{key.inspect}"
81
84
  hash[t.id] = value
82
85
  else
83
- extra[key] = value
86
+ warn "nope #{key.inspect}"
87
+ @extra[key] = value
84
88
  end
85
89
 
86
90
  hash
@@ -90,15 +94,15 @@ class Params::Registry::Instance
90
94
  del = Set[] # mark for deletion
91
95
 
92
96
  # grab the complements now
93
- complements = @content[registry.complement.id] =
94
- registry.complement.process(*struct.fetch(registry.complement.id, []))
97
+ complements = @content[@registry.complement.id] =
98
+ @registry.complement.process(*struct.fetch(@registry.complement.id, []))
95
99
 
96
100
  # warn registry.templates.ranked.inspect
97
101
 
98
102
  # warn complements.class
99
103
 
100
104
  # now we get the ranked templates and pass them through
101
- registry[@group].ranked.each do |templates|
105
+ @registry[@group].ranked.each do |templates|
102
106
  # give me the intersection of templates
103
107
  templates.values.each do |t|
104
108
 
@@ -102,6 +102,15 @@ module Params::Registry::Types
102
102
  s.to_s.upcase.to_sym
103
103
  end
104
104
 
105
+ # This one is symbol-*ish*
106
+ Symbolish = self.Constructor(::Object) do |x|
107
+ if [::String, ::Symbol].any? { |c| x.is_a? c }
108
+ Symbol[x]
109
+ else
110
+ x
111
+ end
112
+ end
113
+
105
114
  # @!group Dates & Times
106
115
 
107
116
  # Ye olde {::Date}
@@ -151,15 +160,16 @@ module Params::Registry::Types
151
160
  input = ::URI.decode_www_form input if input.is_a? ::String
152
161
 
153
162
  case input
154
- when ::Hash then Hash.map(Symbol, Array.of(String))[input]
163
+ when ::Hash then Hash.map(Symbolish, Array.of(String))[input]
155
164
  when ::Array
156
165
  input.reduce({}) do |out, pair|
157
166
  k, *v = Strict::Array.constrained(min_size: 2)[pair]
158
- (out[k.to_sym] ||= []).push(*v)
167
+ (out[Symbolish[k]] ||= []).push(*v)
159
168
  out
160
169
  end
161
170
  else
162
- raise Dry::Types::CoercionError, "not sure what to do with #{input}"
171
+ raise Dry::Types::CoercionError,
172
+ "not sure what to do with #{input.inspect}"
163
173
  end
164
174
  end
165
175
 
@@ -3,6 +3,6 @@
3
3
  module Params
4
4
  class Registry
5
5
  # The module version
6
- VERSION = "0.1.6"
6
+ VERSION = "0.1.7"
7
7
  end
8
8
  end
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.6
4
+ version: 0.1.7
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-06 00:00:00.000000000 Z
11
+ date: 2024-02-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-types