decanter 5.0.0 → 5.1.1

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: 740cf6eead3d1c13d1af276f12bd8f1e54e6052ff8791fffa3a9b133dde61b7c
4
- data.tar.gz: 86eb37227ce42cf1dddfc7676b298f4de0681178b4540800fc6a67d682568542
3
+ metadata.gz: a57a5178cb4b29737d4872970baa96f9d4690c79cdac7afbad283f8dd742aa96
4
+ data.tar.gz: 3f44cd0224d9a8d34d88d92f9df5785cecf933a710325b0dcafc62f035819136
5
5
  SHA512:
6
- metadata.gz: aec4940ffc2ede503acf8ea757eeaf528bc65e0cc1282cc6fe6fc42c1e1a1f6cc27b9292c62946bca1939b7714cf4cf3e53d1da5093318068c95f349e5e77e88
7
- data.tar.gz: 1af26f35262236b5efe518eea6cfc2b9f8716627f136c96f850233d1d34b7c08e7a5c252706e6cf98fe7544a28082f0774b231d7775f8b16a993b243968088b0
6
+ metadata.gz: 849cf0229126b73ec30a4dcd16c6fddf98f2f983db8a4a22c944734436988a5a3fb97fff7fbf4b2c1bdaf21ec9ec70d6215a29f7efe09c203c1a89eec50c2f4e
7
+ data.tar.gz: 51c09a0d3506f7529b20dd7b49c8a049eeacda7a2143cc17173e10fc86f85c34d4ba91e194ba123269dd6b62d30111f0a585fad53c6ebcbac5a5f8901b0bec04
data/Gemfile.lock CHANGED
@@ -1,44 +1,46 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- decanter (5.0.0)
5
- actionpack (>= 7.1.3.2)
4
+ decanter (5.1.1)
5
+ actionpack (>= 7.1.3)
6
6
  activesupport
7
+ rack (>= 3.1.18)
7
8
  rails (>= 7.1.3.2)
8
- rails-html-sanitizer (>= 1.0.4)
9
+ rails-html-sanitizer (>= 1.6.2)
9
10
 
10
11
  GEM
11
12
  remote: https://rubygems.org/
12
13
  specs:
13
- actioncable (7.1.3.2)
14
- actionpack (= 7.1.3.2)
15
- activesupport (= 7.1.3.2)
14
+ actioncable (7.1.6)
15
+ actionpack (= 7.1.6)
16
+ activesupport (= 7.1.6)
16
17
  nio4r (~> 2.0)
17
18
  websocket-driver (>= 0.6.1)
18
19
  zeitwerk (~> 2.6)
19
- actionmailbox (7.1.3.2)
20
- actionpack (= 7.1.3.2)
21
- activejob (= 7.1.3.2)
22
- activerecord (= 7.1.3.2)
23
- activestorage (= 7.1.3.2)
24
- activesupport (= 7.1.3.2)
20
+ actionmailbox (7.1.6)
21
+ actionpack (= 7.1.6)
22
+ activejob (= 7.1.6)
23
+ activerecord (= 7.1.6)
24
+ activestorage (= 7.1.6)
25
+ activesupport (= 7.1.6)
25
26
  mail (>= 2.7.1)
26
27
  net-imap
27
28
  net-pop
28
29
  net-smtp
29
- actionmailer (7.1.3.2)
30
- actionpack (= 7.1.3.2)
31
- actionview (= 7.1.3.2)
32
- activejob (= 7.1.3.2)
33
- activesupport (= 7.1.3.2)
30
+ actionmailer (7.1.6)
31
+ actionpack (= 7.1.6)
32
+ actionview (= 7.1.6)
33
+ activejob (= 7.1.6)
34
+ activesupport (= 7.1.6)
34
35
  mail (~> 2.5, >= 2.5.4)
35
36
  net-imap
36
37
  net-pop
37
38
  net-smtp
38
39
  rails-dom-testing (~> 2.2)
39
- actionpack (7.1.3.2)
40
- actionview (= 7.1.3.2)
41
- activesupport (= 7.1.3.2)
40
+ actionpack (7.1.6)
41
+ actionview (= 7.1.6)
42
+ activesupport (= 7.1.6)
43
+ cgi
42
44
  nokogiri (>= 1.8.5)
43
45
  racc
44
46
  rack (>= 2.2.4)
@@ -46,78 +48,89 @@ GEM
46
48
  rack-test (>= 0.6.3)
47
49
  rails-dom-testing (~> 2.2)
48
50
  rails-html-sanitizer (~> 1.6)
49
- actiontext (7.1.3.2)
50
- actionpack (= 7.1.3.2)
51
- activerecord (= 7.1.3.2)
52
- activestorage (= 7.1.3.2)
53
- activesupport (= 7.1.3.2)
51
+ actiontext (7.1.6)
52
+ actionpack (= 7.1.6)
53
+ activerecord (= 7.1.6)
54
+ activestorage (= 7.1.6)
55
+ activesupport (= 7.1.6)
54
56
  globalid (>= 0.6.0)
55
57
  nokogiri (>= 1.8.5)
56
- actionview (7.1.3.2)
57
- activesupport (= 7.1.3.2)
58
+ actionview (7.1.6)
59
+ activesupport (= 7.1.6)
58
60
  builder (~> 3.1)
61
+ cgi
59
62
  erubi (~> 1.11)
60
63
  rails-dom-testing (~> 2.2)
61
64
  rails-html-sanitizer (~> 1.6)
62
- activejob (7.1.3.2)
63
- activesupport (= 7.1.3.2)
65
+ activejob (7.1.6)
66
+ activesupport (= 7.1.6)
64
67
  globalid (>= 0.3.6)
65
- activemodel (7.1.3.2)
66
- activesupport (= 7.1.3.2)
67
- activerecord (7.1.3.2)
68
- activemodel (= 7.1.3.2)
69
- activesupport (= 7.1.3.2)
68
+ activemodel (7.1.6)
69
+ activesupport (= 7.1.6)
70
+ activerecord (7.1.6)
71
+ activemodel (= 7.1.6)
72
+ activesupport (= 7.1.6)
70
73
  timeout (>= 0.4.0)
71
- activestorage (7.1.3.2)
72
- actionpack (= 7.1.3.2)
73
- activejob (= 7.1.3.2)
74
- activerecord (= 7.1.3.2)
75
- activesupport (= 7.1.3.2)
74
+ activestorage (7.1.6)
75
+ actionpack (= 7.1.6)
76
+ activejob (= 7.1.6)
77
+ activerecord (= 7.1.6)
78
+ activesupport (= 7.1.6)
76
79
  marcel (~> 1.0)
77
- activesupport (7.1.3.2)
80
+ activesupport (7.1.6)
78
81
  base64
82
+ benchmark (>= 0.3)
79
83
  bigdecimal
80
84
  concurrent-ruby (~> 1.0, >= 1.0.2)
81
85
  connection_pool (>= 2.2.5)
82
86
  drb
83
87
  i18n (>= 1.6, < 2)
88
+ logger (>= 1.4.2)
84
89
  minitest (>= 5.1)
85
90
  mutex_m
91
+ securerandom (>= 0.3)
86
92
  tzinfo (~> 2.0)
87
- base64 (0.2.0)
88
- bigdecimal (3.1.7)
89
- builder (3.2.4)
90
- concurrent-ruby (1.2.3)
91
- connection_pool (2.4.1)
93
+ base64 (0.3.0)
94
+ benchmark (0.5.0)
95
+ bigdecimal (4.0.1)
96
+ builder (3.3.0)
97
+ cgi (0.5.1)
98
+ concurrent-ruby (1.3.6)
99
+ connection_pool (3.0.2)
92
100
  crass (1.0.6)
93
- date (3.4.1)
94
- diff-lcs (1.5.1)
101
+ date (3.5.1)
102
+ diff-lcs (1.6.2)
95
103
  docile (1.1.5)
96
- dotenv (3.1.1)
97
- drb (2.2.1)
98
- erubi (1.12.0)
99
- globalid (1.2.1)
104
+ dotenv (3.2.0)
105
+ drb (2.2.3)
106
+ erb (6.0.1)
107
+ erubi (1.13.1)
108
+ globalid (1.3.0)
100
109
  activesupport (>= 6.1)
101
- i18n (1.14.4)
110
+ i18n (1.14.7)
102
111
  concurrent-ruby (~> 1.0)
103
- io-console (0.7.2)
104
- irb (1.13.0)
112
+ io-console (0.8.2)
113
+ irb (1.16.0)
114
+ pp (>= 0.6.0)
105
115
  rdoc (>= 4.0.0)
106
116
  reline (>= 0.4.2)
107
- json (2.7.2)
108
- loofah (2.22.0)
117
+ json (2.18.0)
118
+ logger (1.7.0)
119
+ loofah (2.25.0)
109
120
  crass (~> 1.0.2)
110
121
  nokogiri (>= 1.12.0)
111
- mail (2.8.1)
122
+ mail (2.9.0)
123
+ logger
112
124
  mini_mime (>= 0.1.1)
113
125
  net-imap
114
126
  net-pop
115
127
  net-smtp
116
- marcel (1.0.4)
128
+ marcel (1.1.0)
117
129
  mini_mime (1.1.5)
118
- minitest (5.22.3)
119
- mutex_m (0.2.0)
120
- net-imap (0.5.6)
130
+ minitest (6.0.0)
131
+ prism (~> 1.5)
132
+ mutex_m (0.3.0)
133
+ net-imap (0.6.2)
121
134
  date
122
135
  net-protocol
123
136
  net-pop (0.1.2)
@@ -126,55 +139,64 @@ GEM
126
139
  timeout
127
140
  net-smtp (0.5.1)
128
141
  net-protocol
129
- nio4r (2.7.4)
130
- nokogiri (1.16.4-arm64-darwin)
142
+ nio4r (2.7.5)
143
+ nokogiri (1.18.10-arm64-darwin)
131
144
  racc (~> 1.4)
132
- nokogiri (1.16.4-x86_64-linux)
145
+ nokogiri (1.18.10-x86_64-linux-gnu)
133
146
  racc (~> 1.4)
134
- psych (5.1.2)
147
+ pp (0.6.3)
148
+ prettyprint
149
+ prettyprint (0.2.0)
150
+ prism (1.7.0)
151
+ psych (5.3.1)
152
+ date
135
153
  stringio
136
- racc (1.7.3)
137
- rack (3.0.10)
138
- rack-session (2.0.0)
154
+ racc (1.8.1)
155
+ rack (3.2.4)
156
+ rack-session (2.1.1)
157
+ base64 (>= 0.1.0)
139
158
  rack (>= 3.0.0)
140
- rack-test (2.1.0)
159
+ rack-test (2.2.0)
141
160
  rack (>= 1.3)
142
- rackup (2.1.0)
161
+ rackup (2.3.1)
143
162
  rack (>= 3)
144
- webrick (~> 1.8)
145
- rails (7.1.3.2)
146
- actioncable (= 7.1.3.2)
147
- actionmailbox (= 7.1.3.2)
148
- actionmailer (= 7.1.3.2)
149
- actionpack (= 7.1.3.2)
150
- actiontext (= 7.1.3.2)
151
- actionview (= 7.1.3.2)
152
- activejob (= 7.1.3.2)
153
- activemodel (= 7.1.3.2)
154
- activerecord (= 7.1.3.2)
155
- activestorage (= 7.1.3.2)
156
- activesupport (= 7.1.3.2)
163
+ rails (7.1.6)
164
+ actioncable (= 7.1.6)
165
+ actionmailbox (= 7.1.6)
166
+ actionmailer (= 7.1.6)
167
+ actionpack (= 7.1.6)
168
+ actiontext (= 7.1.6)
169
+ actionview (= 7.1.6)
170
+ activejob (= 7.1.6)
171
+ activemodel (= 7.1.6)
172
+ activerecord (= 7.1.6)
173
+ activestorage (= 7.1.6)
174
+ activesupport (= 7.1.6)
157
175
  bundler (>= 1.15.0)
158
- railties (= 7.1.3.2)
159
- rails-dom-testing (2.2.0)
176
+ railties (= 7.1.6)
177
+ rails-dom-testing (2.3.0)
160
178
  activesupport (>= 5.0.0)
161
179
  minitest
162
180
  nokogiri (>= 1.6)
163
- rails-html-sanitizer (1.6.0)
181
+ rails-html-sanitizer (1.6.2)
164
182
  loofah (~> 2.21)
165
- nokogiri (~> 1.14)
166
- railties (7.1.3.2)
167
- actionpack (= 7.1.3.2)
168
- activesupport (= 7.1.3.2)
183
+ nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
184
+ railties (7.1.6)
185
+ actionpack (= 7.1.6)
186
+ activesupport (= 7.1.6)
187
+ cgi
169
188
  irb
170
189
  rackup (>= 1.0.0)
171
190
  rake (>= 12.2)
172
191
  thor (~> 1.0, >= 1.2.2)
192
+ tsort (>= 0.2)
173
193
  zeitwerk (~> 2.6)
174
194
  rake (12.3.3)
175
- rdoc (6.6.3.1)
195
+ rdoc (7.0.1)
196
+ erb
176
197
  psych (>= 4.0.0)
177
- reline (0.5.5)
198
+ tsort
199
+ reline (0.6.3)
178
200
  io-console (~> 0.5)
179
201
  rspec-core (3.9.3)
180
202
  rspec-support (~> 3.9.3)
@@ -193,26 +215,28 @@ GEM
193
215
  rspec-mocks (~> 3.9.0)
194
216
  rspec-support (~> 3.9.0)
195
217
  rspec-support (3.9.4)
218
+ securerandom (0.4.1)
196
219
  simplecov (0.15.1)
197
220
  docile (~> 1.1.0)
198
221
  json (>= 1.8, < 3)
199
222
  simplecov-html (~> 0.10.0)
200
223
  simplecov-html (0.10.2)
201
- stringio (3.1.0)
202
- thor (1.3.1)
203
- timeout (0.4.3)
224
+ stringio (3.2.0)
225
+ thor (1.4.0)
226
+ timeout (0.6.0)
227
+ tsort (0.2.0)
204
228
  tzinfo (2.0.6)
205
229
  concurrent-ruby (~> 1.0)
206
- webrick (1.8.1)
207
- websocket-driver (0.7.7)
230
+ websocket-driver (0.8.0)
208
231
  base64
209
232
  websocket-extensions (>= 0.1.0)
210
233
  websocket-extensions (0.1.5)
211
- zeitwerk (2.6.13)
234
+ zeitwerk (2.7.4)
212
235
 
213
236
  PLATFORMS
214
237
  arm64-darwin-22
215
238
  arm64-darwin-23
239
+ arm64-darwin-24
216
240
  x86_64-linux
217
241
 
218
242
  DEPENDENCIES
data/README.md CHANGED
@@ -12,21 +12,31 @@ gem 'decanter', '~> 5.0'
12
12
 
13
13
  ## Contents
14
14
 
15
- - [Basic Usage](#basic-usage)
16
- - [Decanters](#decanters)
17
- - [Generators](#generators)
18
- - [Decanting Collections](#decanting-collections)
19
- - [Nested resources](#nested-resources)
20
- - [Default parsers](#default-parsers)
21
- - [Parser options](#parser-options)
22
- - [Exceptions](#exceptions)
23
- - [Advanced usage](#advanced-usage)
24
- - [Custom parsers](#custom-parsers)
25
- - [Squashing inputs](#squashing-inputs)
26
- - [Chaining parsers](#chaining-parsers)
27
- - [Requiring params](#requiring-params)
28
- - [Global configuration](#global-configuration)
29
- - [Contributing](#contributing)
15
+ - [Decanter](#decanter)
16
+ - [Migration Guides](#migration-guides)
17
+ - [Contents](#contents)
18
+ - [Basic Usage](#basic-usage)
19
+ - [Decanters](#decanters)
20
+ - [Generators](#generators)
21
+ - [Decanters](#decanters-1)
22
+ - [Parsers](#parsers)
23
+ - [Resources](#resources)
24
+ - [Decanting Collections](#decanting-collections)
25
+ - [Control Over Decanting Collections](#control-over-decanting-collections)
26
+ - [Nested resources](#nested-resources)
27
+ - [Default parsers](#default-parsers)
28
+ - [Parser options](#parser-options)
29
+ - [Exceptions](#exceptions)
30
+ - [Advanced Usage](#advanced-usage)
31
+ - [Custom Parsers](#custom-parsers)
32
+ - [Custom parser methods](#custom-parser-methods)
33
+ - [Custom parser base classes](#custom-parser-base-classes)
34
+ - [Squashing inputs](#squashing-inputs)
35
+ - [Chaining parsers](#chaining-parsers)
36
+ - [Requiring params](#requiring-params)
37
+ - [Default values](#default-values)
38
+ - [Global configuration](#global-configuration)
39
+ - [Contributing](#contributing)
30
40
 
31
41
  ## Basic Usage
32
42
 
@@ -163,6 +173,7 @@ Decanter comes with the following parsers out of the box:
163
173
  - `:phone`
164
174
  - `:string`
165
175
  - `:array`
176
+ - `:json`
166
177
 
167
178
  Note: these parsers are designed to operate on a single value, except for `:array`. This parser expects an array, and will use the `parse_each` option to call a given parser on each of its elements:
168
179
 
@@ -170,6 +181,11 @@ Note: these parsers are designed to operate on a single value, except for `:arra
170
181
  input :ids, :array, parse_each: :integer
171
182
  ```
172
183
 
184
+ The `:json` parser may also accept an array, but the array must be provided as a single JSON-encoded string value:
185
+ ```
186
+ '["abc", "def"]'
187
+ ```
188
+
173
189
  ### Parser options
174
190
 
175
191
  Some parsers can receive options that modify their behavior. These options are passed in as named arguments to `input`:
data/decanter.gemspec CHANGED
@@ -26,9 +26,10 @@ Gem::Specification.new do |spec|
26
26
  spec.require_paths = ['lib']
27
27
 
28
28
  spec.add_dependency 'rails', '>= 7.1.3.2'
29
- spec.add_dependency 'actionpack', '>= 7.1.3.2'
29
+ spec.add_dependency 'actionpack', '>= 7.1.3'
30
30
  spec.add_dependency 'activesupport'
31
- spec.add_dependency 'rails-html-sanitizer', '>= 1.0.4'
31
+ spec.add_dependency 'rack', '>= 3.1.18'
32
+ spec.add_dependency 'rails-html-sanitizer', '>= 1.6.2'
32
33
 
33
34
  spec.add_development_dependency 'bundler', '~> 2.4.22'
34
35
  spec.add_development_dependency 'dotenv'
@@ -0,0 +1,20 @@
1
+ module Decanter
2
+ module Parser
3
+ class JsonParser < ValueParser
4
+
5
+ parser do |val, options|
6
+ next if val.nil? || val === ''
7
+ raise Decanter::ParseError.new 'Expects a JSON string' unless val.is_a?(String)
8
+ parse_json(val)
9
+ end
10
+
11
+ def self.parse_json(val)
12
+ begin
13
+ JSON.parse(val)
14
+ rescue
15
+ raise Decanter::ParseError.new 'Invalid JSON string'
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -1,3 +1,3 @@
1
1
  module Decanter
2
- VERSION = '5.0.0'.freeze
2
+ VERSION = '5.1.1'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: decanter
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.0
4
+ version: 5.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Francis
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2025-04-04 00:00:00.000000000 Z
12
+ date: 2025-12-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -31,14 +31,14 @@ dependencies:
31
31
  requirements:
32
32
  - - ">="
33
33
  - !ruby/object:Gem::Version
34
- version: 7.1.3.2
34
+ version: 7.1.3
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - ">="
40
40
  - !ruby/object:Gem::Version
41
- version: 7.1.3.2
41
+ version: 7.1.3
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: activesupport
44
44
  requirement: !ruby/object:Gem::Requirement
@@ -53,20 +53,34 @@ dependencies:
53
53
  - - ">="
54
54
  - !ruby/object:Gem::Version
55
55
  version: '0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: rack
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: 3.1.18
63
+ type: :runtime
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: 3.1.18
56
70
  - !ruby/object:Gem::Dependency
57
71
  name: rails-html-sanitizer
58
72
  requirement: !ruby/object:Gem::Requirement
59
73
  requirements:
60
74
  - - ">="
61
75
  - !ruby/object:Gem::Version
62
- version: 1.0.4
76
+ version: 1.6.2
63
77
  type: :runtime
64
78
  prerelease: false
65
79
  version_requirements: !ruby/object:Gem::Requirement
66
80
  requirements:
67
81
  - - ">="
68
82
  - !ruby/object:Gem::Version
69
- version: 1.0.4
83
+ version: 1.6.2
70
84
  - !ruby/object:Gem::Dependency
71
85
  name: bundler
72
86
  requirement: !ruby/object:Gem::Requirement
@@ -184,6 +198,7 @@ files:
184
198
  - lib/decanter/parser/float_parser.rb
185
199
  - lib/decanter/parser/hash_parser.rb
186
200
  - lib/decanter/parser/integer_parser.rb
201
+ - lib/decanter/parser/json_parser.rb
187
202
  - lib/decanter/parser/pass_parser.rb
188
203
  - lib/decanter/parser/phone_parser.rb
189
204
  - lib/decanter/parser/string_parser.rb
@@ -221,7 +236,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
221
236
  - !ruby/object:Gem::Version
222
237
  version: '0'
223
238
  requirements: []
224
- rubygems_version: 3.5.16
239
+ rubygems_version: 3.5.3
225
240
  signing_key:
226
241
  specification_version: 4
227
242
  summary: Form Parser for Rails