active_interaction 4.0.6 → 5.1.0

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.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +156 -7
  3. data/CONTRIBUTING.md +11 -3
  4. data/README.md +260 -219
  5. data/lib/active_interaction/array_input.rb +77 -0
  6. data/lib/active_interaction/base.rb +14 -98
  7. data/lib/active_interaction/concerns/active_recordable.rb +3 -3
  8. data/lib/active_interaction/concerns/missable.rb +2 -2
  9. data/lib/active_interaction/errors.rb +6 -88
  10. data/lib/active_interaction/exceptions.rb +47 -0
  11. data/lib/active_interaction/filter/column.rb +59 -0
  12. data/lib/active_interaction/filter/error.rb +40 -0
  13. data/lib/active_interaction/filter.rb +44 -53
  14. data/lib/active_interaction/filters/abstract_date_time_filter.rb +9 -6
  15. data/lib/active_interaction/filters/abstract_numeric_filter.rb +7 -3
  16. data/lib/active_interaction/filters/array_filter.rb +40 -6
  17. data/lib/active_interaction/filters/boolean_filter.rb +4 -3
  18. data/lib/active_interaction/filters/date_filter.rb +1 -1
  19. data/lib/active_interaction/filters/date_time_filter.rb +1 -1
  20. data/lib/active_interaction/filters/decimal_filter.rb +1 -1
  21. data/lib/active_interaction/filters/float_filter.rb +1 -1
  22. data/lib/active_interaction/filters/hash_filter.rb +23 -15
  23. data/lib/active_interaction/filters/integer_filter.rb +1 -1
  24. data/lib/active_interaction/filters/interface_filter.rb +12 -12
  25. data/lib/active_interaction/filters/object_filter.rb +9 -3
  26. data/lib/active_interaction/filters/record_filter.rb +21 -11
  27. data/lib/active_interaction/filters/string_filter.rb +1 -1
  28. data/lib/active_interaction/filters/symbol_filter.rb +1 -1
  29. data/lib/active_interaction/filters/time_filter.rb +4 -4
  30. data/lib/active_interaction/hash_input.rb +43 -0
  31. data/lib/active_interaction/input.rb +23 -0
  32. data/lib/active_interaction/inputs.rb +161 -46
  33. data/lib/active_interaction/locale/en.yml +0 -1
  34. data/lib/active_interaction/locale/fr.yml +0 -1
  35. data/lib/active_interaction/locale/it.yml +0 -1
  36. data/lib/active_interaction/locale/ja.yml +0 -1
  37. data/lib/active_interaction/locale/pt-BR.yml +0 -1
  38. data/lib/active_interaction/modules/validation.rb +6 -17
  39. data/lib/active_interaction/version.rb +1 -1
  40. data/lib/active_interaction.rb +41 -36
  41. data/spec/active_interaction/array_input_spec.rb +166 -0
  42. data/spec/active_interaction/base_spec.rb +34 -248
  43. data/spec/active_interaction/concerns/active_modelable_spec.rb +3 -3
  44. data/spec/active_interaction/concerns/active_recordable_spec.rb +7 -7
  45. data/spec/active_interaction/concerns/hashable_spec.rb +8 -8
  46. data/spec/active_interaction/concerns/missable_spec.rb +9 -9
  47. data/spec/active_interaction/concerns/runnable_spec.rb +34 -32
  48. data/spec/active_interaction/errors_spec.rb +60 -43
  49. data/spec/active_interaction/{filter_column_spec.rb → filter/column_spec.rb} +3 -10
  50. data/spec/active_interaction/filter_spec.rb +6 -6
  51. data/spec/active_interaction/filters/abstract_date_time_filter_spec.rb +2 -2
  52. data/spec/active_interaction/filters/abstract_numeric_filter_spec.rb +2 -2
  53. data/spec/active_interaction/filters/array_filter_spec.rb +109 -16
  54. data/spec/active_interaction/filters/boolean_filter_spec.rb +12 -11
  55. data/spec/active_interaction/filters/date_filter_spec.rb +32 -27
  56. data/spec/active_interaction/filters/date_time_filter_spec.rb +34 -29
  57. data/spec/active_interaction/filters/decimal_filter_spec.rb +20 -18
  58. data/spec/active_interaction/filters/file_filter_spec.rb +7 -7
  59. data/spec/active_interaction/filters/float_filter_spec.rb +19 -17
  60. data/spec/active_interaction/filters/hash_filter_spec.rb +16 -18
  61. data/spec/active_interaction/filters/integer_filter_spec.rb +24 -22
  62. data/spec/active_interaction/filters/interface_filter_spec.rb +105 -82
  63. data/spec/active_interaction/filters/object_filter_spec.rb +52 -36
  64. data/spec/active_interaction/filters/record_filter_spec.rb +61 -39
  65. data/spec/active_interaction/filters/string_filter_spec.rb +7 -7
  66. data/spec/active_interaction/filters/symbol_filter_spec.rb +6 -6
  67. data/spec/active_interaction/filters/time_filter_spec.rb +57 -34
  68. data/spec/active_interaction/hash_input_spec.rb +58 -0
  69. data/spec/active_interaction/i18n_spec.rb +22 -17
  70. data/spec/active_interaction/inputs_spec.rb +170 -18
  71. data/spec/active_interaction/integration/array_interaction_spec.rb +3 -7
  72. data/spec/active_interaction/integration/record_integration_spec.rb +5 -0
  73. data/spec/active_interaction/modules/validation_spec.rb +8 -31
  74. data/spec/spec_helper.rb +9 -0
  75. data/spec/support/concerns.rb +2 -2
  76. data/spec/support/filters.rb +27 -51
  77. data/spec/support/interactions.rb +4 -4
  78. metadata +50 -50
  79. data/lib/active_interaction/filter_column.rb +0 -57
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_interaction
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.6
4
+ version: 5.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Lasseigne
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-10-14 00:00:00.000000000 Z
12
+ date: 2022-07-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activemodel
@@ -17,40 +17,40 @@ dependencies:
17
17
  requirements:
18
18
  - - ">="
19
19
  - !ruby/object:Gem::Version
20
- version: '5'
20
+ version: '5.2'
21
21
  - - "<"
22
22
  - !ruby/object:Gem::Version
23
- version: '7'
23
+ version: '8'
24
24
  type: :runtime
25
25
  prerelease: false
26
26
  version_requirements: !ruby/object:Gem::Requirement
27
27
  requirements:
28
28
  - - ">="
29
29
  - !ruby/object:Gem::Version
30
- version: '5'
30
+ version: '5.2'
31
31
  - - "<"
32
32
  - !ruby/object:Gem::Version
33
- version: '7'
33
+ version: '8'
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: activesupport
36
36
  requirement: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '5'
40
+ version: '5.2'
41
41
  - - "<"
42
42
  - !ruby/object:Gem::Version
43
- version: '7'
43
+ version: '8'
44
44
  type: :runtime
45
45
  prerelease: false
46
46
  version_requirements: !ruby/object:Gem::Requirement
47
47
  requirements:
48
48
  - - ">="
49
49
  - !ruby/object:Gem::Version
50
- version: '5'
50
+ version: '5.2'
51
51
  - - "<"
52
52
  - !ruby/object:Gem::Version
53
- version: '7'
53
+ version: '8'
54
54
  - !ruby/object:Gem::Dependency
55
55
  name: actionpack
56
56
  requirement: !ruby/object:Gem::Requirement
@@ -79,20 +79,6 @@ dependencies:
79
79
  - - ">="
80
80
  - !ruby/object:Gem::Version
81
81
  version: '0'
82
- - !ruby/object:Gem::Dependency
83
- name: benchmark-ips
84
- requirement: !ruby/object:Gem::Requirement
85
- requirements:
86
- - - "~>"
87
- - !ruby/object:Gem::Version
88
- version: '2.7'
89
- type: :development
90
- prerelease: false
91
- version_requirements: !ruby/object:Gem::Requirement
92
- requirements:
93
- - - "~>"
94
- - !ruby/object:Gem::Version
95
- version: '2.7'
96
82
  - !ruby/object:Gem::Dependency
97
83
  name: kramdown
98
84
  requirement: !ruby/object:Gem::Requirement
@@ -141,73 +127,75 @@ dependencies:
141
127
  requirements:
142
128
  - - "~>"
143
129
  - !ruby/object:Gem::Version
144
- version: 1.17.0
130
+ version: 1.26.1
145
131
  type: :development
146
132
  prerelease: false
147
133
  version_requirements: !ruby/object:Gem::Requirement
148
134
  requirements:
149
135
  - - "~>"
150
136
  - !ruby/object:Gem::Version
151
- version: 1.17.0
137
+ version: 1.26.1
152
138
  - !ruby/object:Gem::Dependency
153
139
  name: rubocop-rake
154
140
  requirement: !ruby/object:Gem::Requirement
155
141
  requirements:
156
142
  - - "~>"
157
143
  - !ruby/object:Gem::Version
158
- version: 0.5.1
144
+ version: 0.6.0
159
145
  type: :development
160
146
  prerelease: false
161
147
  version_requirements: !ruby/object:Gem::Requirement
162
148
  requirements:
163
149
  - - "~>"
164
150
  - !ruby/object:Gem::Version
165
- version: 0.5.1
151
+ version: 0.6.0
166
152
  - !ruby/object:Gem::Dependency
167
153
  name: rubocop-rspec
168
154
  requirement: !ruby/object:Gem::Requirement
169
155
  requirements:
170
156
  - - "~>"
171
157
  - !ruby/object:Gem::Version
172
- version: '2.1'
158
+ version: 2.9.0
173
159
  type: :development
174
160
  prerelease: false
175
161
  version_requirements: !ruby/object:Gem::Requirement
176
162
  requirements:
177
163
  - - "~>"
178
164
  - !ruby/object:Gem::Version
179
- version: '2.1'
165
+ version: 2.9.0
180
166
  - !ruby/object:Gem::Dependency
181
- name: yard
167
+ name: sqlite3
182
168
  requirement: !ruby/object:Gem::Requirement
183
169
  requirements:
184
- - - "~>"
170
+ - - ">="
185
171
  - !ruby/object:Gem::Version
186
- version: '0.9'
172
+ version: '0'
187
173
  type: :development
188
174
  prerelease: false
189
175
  version_requirements: !ruby/object:Gem::Requirement
190
176
  requirements:
191
- - - "~>"
177
+ - - ">="
192
178
  - !ruby/object:Gem::Version
193
- version: '0.9'
179
+ version: '0'
194
180
  - !ruby/object:Gem::Dependency
195
- name: sqlite3
181
+ name: yard
196
182
  requirement: !ruby/object:Gem::Requirement
197
183
  requirements:
198
- - - ">="
184
+ - - "~>"
199
185
  - !ruby/object:Gem::Version
200
- version: '0'
186
+ version: '0.9'
201
187
  type: :development
202
188
  prerelease: false
203
189
  version_requirements: !ruby/object:Gem::Requirement
204
190
  requirements:
205
- - - ">="
191
+ - - "~>"
206
192
  - !ruby/object:Gem::Version
207
- version: '0'
208
- description: |2
209
- ActiveInteraction manages application-specific business logic. It is an
210
- implementation of the command pattern in Ruby.
193
+ version: '0.9'
194
+ description: |
195
+ ActiveInteraction manages application-specific business logic. It is an
196
+ implementation of what are called service objects, interactors, or the
197
+ command pattern. No matter what you call it, its built to work seamlessly
198
+ with Rails.
211
199
  email:
212
200
  - aaron.lasseigne@gmail.com
213
201
  - taylor@fausak.me
@@ -220,6 +208,7 @@ files:
220
208
  - LICENSE.md
221
209
  - README.md
222
210
  - lib/active_interaction.rb
211
+ - lib/active_interaction/array_input.rb
223
212
  - lib/active_interaction/base.rb
224
213
  - lib/active_interaction/concerns/active_modelable.rb
225
214
  - lib/active_interaction/concerns/active_recordable.rb
@@ -227,8 +216,10 @@ files:
227
216
  - lib/active_interaction/concerns/missable.rb
228
217
  - lib/active_interaction/concerns/runnable.rb
229
218
  - lib/active_interaction/errors.rb
219
+ - lib/active_interaction/exceptions.rb
230
220
  - lib/active_interaction/filter.rb
231
- - lib/active_interaction/filter_column.rb
221
+ - lib/active_interaction/filter/column.rb
222
+ - lib/active_interaction/filter/error.rb
232
223
  - lib/active_interaction/filters/abstract_date_time_filter.rb
233
224
  - lib/active_interaction/filters/abstract_numeric_filter.rb
234
225
  - lib/active_interaction/filters/array_filter.rb
@@ -247,6 +238,8 @@ files:
247
238
  - lib/active_interaction/filters/symbol_filter.rb
248
239
  - lib/active_interaction/filters/time_filter.rb
249
240
  - lib/active_interaction/grouped_input.rb
241
+ - lib/active_interaction/hash_input.rb
242
+ - lib/active_interaction/input.rb
250
243
  - lib/active_interaction/inputs.rb
251
244
  - lib/active_interaction/locale/en.yml
252
245
  - lib/active_interaction/locale/fr.yml
@@ -255,6 +248,7 @@ files:
255
248
  - lib/active_interaction/locale/pt-BR.yml
256
249
  - lib/active_interaction/modules/validation.rb
257
250
  - lib/active_interaction/version.rb
251
+ - spec/active_interaction/array_input_spec.rb
258
252
  - spec/active_interaction/base_spec.rb
259
253
  - spec/active_interaction/concerns/active_modelable_spec.rb
260
254
  - spec/active_interaction/concerns/active_recordable_spec.rb
@@ -262,7 +256,7 @@ files:
262
256
  - spec/active_interaction/concerns/missable_spec.rb
263
257
  - spec/active_interaction/concerns/runnable_spec.rb
264
258
  - spec/active_interaction/errors_spec.rb
265
- - spec/active_interaction/filter_column_spec.rb
259
+ - spec/active_interaction/filter/column_spec.rb
266
260
  - spec/active_interaction/filter_spec.rb
267
261
  - spec/active_interaction/filters/abstract_date_time_filter_spec.rb
268
262
  - spec/active_interaction/filters/abstract_numeric_filter_spec.rb
@@ -282,6 +276,7 @@ files:
282
276
  - spec/active_interaction/filters/symbol_filter_spec.rb
283
277
  - spec/active_interaction/filters/time_filter_spec.rb
284
278
  - spec/active_interaction/grouped_input_spec.rb
279
+ - spec/active_interaction/hash_input_spec.rb
285
280
  - spec/active_interaction/i18n_spec.rb
286
281
  - spec/active_interaction/inputs_spec.rb
287
282
  - spec/active_interaction/integration/array_interaction_spec.rb
@@ -294,6 +289,7 @@ files:
294
289
  - spec/active_interaction/integration/integer_interaction_spec.rb
295
290
  - spec/active_interaction/integration/interface_interaction_spec.rb
296
291
  - spec/active_interaction/integration/object_interaction_spec.rb
292
+ - spec/active_interaction/integration/record_integration_spec.rb
297
293
  - spec/active_interaction/integration/string_interaction_spec.rb
298
294
  - spec/active_interaction/integration/symbol_interaction_spec.rb
299
295
  - spec/active_interaction/integration/time_interaction_spec.rb
@@ -302,13 +298,14 @@ files:
302
298
  - spec/support/concerns.rb
303
299
  - spec/support/filters.rb
304
300
  - spec/support/interactions.rb
305
- homepage:
301
+ homepage: https://github.com/AaronLasseigne/active_interaction
306
302
  licenses:
307
303
  - MIT
308
304
  metadata:
309
305
  homepage_uri: https://github.com/AaronLasseigne/active_interaction
310
306
  source_code_uri: https://github.com/AaronLasseigne/active_interaction
311
- changelog_uri: https://github.com/AaronLasseigne/active_interaction/blob/master/CHANGELOG.md
307
+ changelog_uri: https://github.com/AaronLasseigne/active_interaction/blob/main/CHANGELOG.md
308
+ rubygems_mfa_required: 'true'
312
309
  post_install_message:
313
310
  rdoc_options: []
314
311
  require_paths:
@@ -317,18 +314,19 @@ required_ruby_version: !ruby/object:Gem::Requirement
317
314
  requirements:
318
315
  - - ">="
319
316
  - !ruby/object:Gem::Version
320
- version: '2.5'
317
+ version: '2.7'
321
318
  required_rubygems_version: !ruby/object:Gem::Requirement
322
319
  requirements:
323
320
  - - ">="
324
321
  - !ruby/object:Gem::Version
325
322
  version: '0'
326
323
  requirements: []
327
- rubygems_version: 3.2.15
324
+ rubygems_version: 3.3.7
328
325
  signing_key:
329
326
  specification_version: 4
330
327
  summary: Manage application specific business logic.
331
328
  test_files:
329
+ - spec/active_interaction/array_input_spec.rb
332
330
  - spec/active_interaction/base_spec.rb
333
331
  - spec/active_interaction/concerns/active_modelable_spec.rb
334
332
  - spec/active_interaction/concerns/active_recordable_spec.rb
@@ -336,7 +334,7 @@ test_files:
336
334
  - spec/active_interaction/concerns/missable_spec.rb
337
335
  - spec/active_interaction/concerns/runnable_spec.rb
338
336
  - spec/active_interaction/errors_spec.rb
339
- - spec/active_interaction/filter_column_spec.rb
337
+ - spec/active_interaction/filter/column_spec.rb
340
338
  - spec/active_interaction/filter_spec.rb
341
339
  - spec/active_interaction/filters/abstract_date_time_filter_spec.rb
342
340
  - spec/active_interaction/filters/abstract_numeric_filter_spec.rb
@@ -356,6 +354,7 @@ test_files:
356
354
  - spec/active_interaction/filters/symbol_filter_spec.rb
357
355
  - spec/active_interaction/filters/time_filter_spec.rb
358
356
  - spec/active_interaction/grouped_input_spec.rb
357
+ - spec/active_interaction/hash_input_spec.rb
359
358
  - spec/active_interaction/i18n_spec.rb
360
359
  - spec/active_interaction/inputs_spec.rb
361
360
  - spec/active_interaction/integration/array_interaction_spec.rb
@@ -368,6 +367,7 @@ test_files:
368
367
  - spec/active_interaction/integration/integer_interaction_spec.rb
369
368
  - spec/active_interaction/integration/interface_interaction_spec.rb
370
369
  - spec/active_interaction/integration/object_interaction_spec.rb
370
+ - spec/active_interaction/integration/record_integration_spec.rb
371
371
  - spec/active_interaction/integration/string_interaction_spec.rb
372
372
  - spec/active_interaction/integration/symbol_interaction_spec.rb
373
373
  - spec/active_interaction/integration/time_interaction_spec.rb
@@ -1,57 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ActiveInteraction
4
- # A minimal implementation of an `ActiveRecord::ConnectionAdapters::Column`.
5
- class FilterColumn
6
- # @return [nil]
7
- attr_reader :limit
8
-
9
- # @return [Symbol]
10
- attr_reader :type
11
-
12
- class << self
13
- # Find or create the `FilterColumn` for a specific type.
14
- #
15
- # @param type [Symbol] A database column type.
16
- #
17
- # @example
18
- # FilterColumn.intern(:string)
19
- # # => #<ActiveInteraction::FilterColumn:0x007feeaa649c @type=:string>
20
- #
21
- # FilterColumn.intern(:string)
22
- # # => #<ActiveInteraction::FilterColumn:0x007feeaa649c @type=:string>
23
- #
24
- # FilterColumn.intern(:boolean)
25
- # # => #<ActiveInteraction::FilterColumn:0x007feeab8a08 @type=:boolean>
26
- #
27
- # @return [FilterColumn]
28
- def intern(type)
29
- @columns ||= {}
30
- @columns[type] ||= new(type)
31
- end
32
-
33
- private :new
34
- end
35
-
36
- # @param type [type] The database column type.
37
- #
38
- # @private
39
- def initialize(type)
40
- @type = type
41
- end
42
-
43
- # Returns `true` if the column is either of type :integer or :float.
44
- #
45
- # @return [Boolean]
46
- def number?
47
- %i[integer float].include?(type)
48
- end
49
-
50
- # Returns `true` if the column is of type :string.
51
- #
52
- # @return [Boolean]
53
- def text?
54
- type == :string
55
- end
56
- end
57
- end