cmdx 1.11.0 → 1.12.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.
- checksums.yaml +4 -4
- data/.cursor/rules/cursor-instructions.mdc +8 -0
- data/.yard-lint.yml +174 -0
- data/CHANGELOG.md +15 -0
- data/docs/attributes/definitions.md +5 -1
- data/docs/attributes/validations.md +47 -6
- data/docs/outcomes/result.md +8 -7
- data/docs/outcomes/states.md +4 -4
- data/docs/outcomes/statuses.md +6 -6
- data/docs/tips_and_tricks.md +4 -0
- data/examples/active_record_database_transaction.md +27 -0
- data/examples/flipper_feature_flags.md +50 -0
- data/examples/redis_idempotency.md +71 -0
- data/examples/sentry_error_tracking.md +46 -0
- data/lib/cmdx/attribute.rb +6 -0
- data/lib/cmdx/callback_registry.rb +2 -1
- data/lib/cmdx/chain.rb +2 -3
- data/lib/cmdx/coercion_registry.rb +2 -1
- data/lib/cmdx/coercions/boolean.rb +3 -3
- data/lib/cmdx/coercions/complex.rb +1 -0
- data/lib/cmdx/coercions/string.rb +1 -0
- data/lib/cmdx/coercions/symbol.rb +1 -0
- data/lib/cmdx/configuration.rb +1 -3
- data/lib/cmdx/context.rb +3 -2
- data/lib/cmdx/middleware_registry.rb +1 -0
- data/lib/cmdx/result.rb +8 -88
- data/lib/cmdx/task.rb +7 -10
- data/lib/cmdx/utils/call.rb +3 -1
- data/lib/cmdx/utils/condition.rb +0 -3
- data/lib/cmdx/utils/format.rb +1 -1
- data/lib/cmdx/validators/exclusion.rb +2 -0
- data/lib/cmdx/validators/inclusion.rb +2 -0
- data/lib/cmdx/validators/length.rb +6 -0
- data/lib/cmdx/validators/numeric.rb +6 -0
- data/lib/cmdx/version.rb +1 -1
- data/lib/generators/cmdx/locale_generator.rb +6 -5
- metadata +20 -1
|
@@ -53,9 +53,9 @@ module CMDx
|
|
|
53
53
|
# @param type [Symbol] The callback type from TYPES
|
|
54
54
|
# @param callables [Array<#call>] Callable objects to register
|
|
55
55
|
# @param options [Hash] Options to pass to the callback
|
|
56
|
+
# @param block [Proc] Optional block to register as a callable
|
|
56
57
|
# @option options [Hash] :if Condition hash for conditional execution
|
|
57
58
|
# @option options [Hash] :unless Inverse condition hash for conditional execution
|
|
58
|
-
# @param block [Proc] Optional block to register as a callable
|
|
59
59
|
#
|
|
60
60
|
# @return [CallbackRegistry] self for method chaining
|
|
61
61
|
#
|
|
@@ -83,6 +83,7 @@ module CMDx
|
|
|
83
83
|
# @param callables [Array<#call>] Callable objects to remove
|
|
84
84
|
# @param options [Hash] Options that were used during registration
|
|
85
85
|
# @param block [Proc] Optional block to remove
|
|
86
|
+
# @option options [Object] :* Any option key-value pairs
|
|
86
87
|
#
|
|
87
88
|
# @return [CallbackRegistry] self for method chaining
|
|
88
89
|
#
|
data/lib/cmdx/chain.rb
CHANGED
|
@@ -114,12 +114,11 @@ module CMDx
|
|
|
114
114
|
|
|
115
115
|
# Converts the chain to a hash representation.
|
|
116
116
|
#
|
|
117
|
-
# @return [Hash] Hash containing chain id and serialized results
|
|
118
|
-
#
|
|
119
117
|
# @option return [String] :id The chain identifier
|
|
120
|
-
#
|
|
121
118
|
# @option return [Array<Hash>] :results Array of result hashes
|
|
122
119
|
#
|
|
120
|
+
# @return [Hash] Hash containing chain id and serialized results
|
|
121
|
+
#
|
|
123
122
|
# @example
|
|
124
123
|
# chain_hash = chain.to_h
|
|
125
124
|
# puts chain_hash[:id]
|
|
@@ -20,7 +20,7 @@ module CMDx
|
|
|
20
20
|
|
|
21
21
|
# Initialize a new coercion registry.
|
|
22
22
|
#
|
|
23
|
-
# @param registry [Hash
|
|
23
|
+
# @param registry [Hash{Symbol => Class}, nil] optional initial registry hash
|
|
24
24
|
#
|
|
25
25
|
# @example
|
|
26
26
|
# registry = CoercionRegistry.new
|
|
@@ -95,6 +95,7 @@ module CMDx
|
|
|
95
95
|
# @param task [Object] the task context for the coercion
|
|
96
96
|
# @param value [Object] the value to coerce
|
|
97
97
|
# @param options [Hash] additional options for the coercion
|
|
98
|
+
# @option options [Object] :* Any coercion option key-value pairs
|
|
98
99
|
#
|
|
99
100
|
# @return [Object] the coerced value
|
|
100
101
|
#
|
|
@@ -11,10 +11,10 @@ module CMDx
|
|
|
11
11
|
extend self
|
|
12
12
|
|
|
13
13
|
# @rbs FALSEY: Regexp
|
|
14
|
-
FALSEY =
|
|
14
|
+
FALSEY = /\A(false|f|no|n|0)\z/i
|
|
15
15
|
|
|
16
16
|
# @rbs TRUTHY: Regexp
|
|
17
|
-
TRUTHY =
|
|
17
|
+
TRUTHY = /\A(true|t|yes|y|1)\z/i
|
|
18
18
|
|
|
19
19
|
# Converts a value to a Boolean
|
|
20
20
|
#
|
|
@@ -40,7 +40,7 @@ module CMDx
|
|
|
40
40
|
#
|
|
41
41
|
# @rbs (untyped value, ?Hash[Symbol, untyped] options) -> bool
|
|
42
42
|
def call(value, options = {})
|
|
43
|
-
case value.to_s
|
|
43
|
+
case value.to_s
|
|
44
44
|
when FALSEY then false
|
|
45
45
|
when TRUTHY then true
|
|
46
46
|
else
|
|
@@ -14,6 +14,7 @@ module CMDx
|
|
|
14
14
|
#
|
|
15
15
|
# @param value [Object] The value to convert to Complex
|
|
16
16
|
# @param options [Hash] Optional configuration parameters (currently unused)
|
|
17
|
+
# @option options [Object] :* Any configuration option (unused)
|
|
17
18
|
#
|
|
18
19
|
# @return [Complex] The converted Complex number value
|
|
19
20
|
#
|
|
@@ -15,6 +15,7 @@ module CMDx
|
|
|
15
15
|
#
|
|
16
16
|
# @param value [Object] The value to coerce to a string
|
|
17
17
|
# @param options [Hash] Optional configuration parameters (unused in this coercion)
|
|
18
|
+
# @option options [Object] :* Any configuration option (unused)
|
|
18
19
|
#
|
|
19
20
|
# @return [String] The coerced string value
|
|
20
21
|
#
|
|
@@ -15,6 +15,7 @@ module CMDx
|
|
|
15
15
|
#
|
|
16
16
|
# @param value [Object] The value to coerce to a symbol
|
|
17
17
|
# @param options [Hash] Optional configuration parameters (unused in this coercion)
|
|
18
|
+
# @option options [Object] :* Any configuration option (unused)
|
|
18
19
|
#
|
|
19
20
|
# @return [Symbol] The coerced symbol value
|
|
20
21
|
#
|
data/lib/cmdx/configuration.rb
CHANGED
|
@@ -160,7 +160,7 @@ module CMDx
|
|
|
160
160
|
|
|
161
161
|
# Converts the configuration to a hash representation.
|
|
162
162
|
#
|
|
163
|
-
# @return [Hash
|
|
163
|
+
# @return [Hash{Symbol => Object}] hash containing all configuration values
|
|
164
164
|
#
|
|
165
165
|
# @example
|
|
166
166
|
# config = Configuration.new
|
|
@@ -205,8 +205,6 @@ module CMDx
|
|
|
205
205
|
|
|
206
206
|
# Configures CMDx using a block that receives the configuration instance.
|
|
207
207
|
#
|
|
208
|
-
# @param block [Proc] the configuration block
|
|
209
|
-
#
|
|
210
208
|
# @yield [Configuration] the configuration instance to configure
|
|
211
209
|
#
|
|
212
210
|
# @return [Configuration] the configured configuration instance
|
data/lib/cmdx/context.rb
CHANGED
|
@@ -109,7 +109,6 @@ module CMDx
|
|
|
109
109
|
# Fetches a value from the context by key, with optional default value.
|
|
110
110
|
#
|
|
111
111
|
# @param key [String, Symbol] the key to fetch
|
|
112
|
-
# @param default [Object] the default value if key is not found
|
|
113
112
|
#
|
|
114
113
|
# @yield [key] a block to compute the default value
|
|
115
114
|
#
|
|
@@ -255,6 +254,7 @@ module CMDx
|
|
|
255
254
|
# @param method_name [Symbol] the method name that was called
|
|
256
255
|
# @param args [Array<Object>] arguments passed to the method
|
|
257
256
|
# @param _kwargs [Hash] keyword arguments (unused)
|
|
257
|
+
# @option _kwargs [Object] :* Any keyword arguments (unused)
|
|
258
258
|
#
|
|
259
259
|
# @yield [Object] optional block
|
|
260
260
|
#
|
|
@@ -263,7 +263,8 @@ module CMDx
|
|
|
263
263
|
# @rbs (Symbol method_name, *untyped args, **untyped _kwargs) ?{ () -> untyped } -> untyped
|
|
264
264
|
def method_missing(method_name, *args, **_kwargs, &)
|
|
265
265
|
fetch(method_name) do
|
|
266
|
-
|
|
266
|
+
str_name = method_name.to_s
|
|
267
|
+
store(str_name.chop, args.first) if str_name.end_with?("=")
|
|
267
268
|
end
|
|
268
269
|
end
|
|
269
270
|
|
|
@@ -109,6 +109,7 @@ module CMDx
|
|
|
109
109
|
#
|
|
110
110
|
# @param index [Integer] Current middleware index in the chain
|
|
111
111
|
# @param task [Object] The task object being processed
|
|
112
|
+
# @param block [Proc] Block to execute after middleware processing
|
|
112
113
|
#
|
|
113
114
|
# @yield [task] Block to execute after middleware processing
|
|
114
115
|
# @yieldparam task [Object] The processed task object
|
data/lib/cmdx/result.rb
CHANGED
|
@@ -129,26 +129,6 @@ module CMDx
|
|
|
129
129
|
#
|
|
130
130
|
# @rbs () -> bool
|
|
131
131
|
define_method(:"#{s}?") { state == s }
|
|
132
|
-
|
|
133
|
-
# @param block [Proc] Block to execute conditionally
|
|
134
|
-
#
|
|
135
|
-
# @yield [self] Executes the block if result is in specified state
|
|
136
|
-
#
|
|
137
|
-
# @return [self] Returns self for method chaining
|
|
138
|
-
#
|
|
139
|
-
# @raise [ArgumentError] When no block is provided
|
|
140
|
-
#
|
|
141
|
-
# @example
|
|
142
|
-
# result.handle_initialized { |r| puts "Starting execution" }
|
|
143
|
-
# result.handle_complete { |r| puts "Task completed" }
|
|
144
|
-
#
|
|
145
|
-
# @rbs () { (Result) -> void } -> self
|
|
146
|
-
define_method(:"handle_#{s}") do |&block|
|
|
147
|
-
raise ArgumentError, "block required" unless block
|
|
148
|
-
|
|
149
|
-
block.call(self) if send(:"#{s}?")
|
|
150
|
-
self
|
|
151
|
-
end
|
|
152
132
|
end
|
|
153
133
|
|
|
154
134
|
# @return [self] Returns self for method chaining
|
|
@@ -171,25 +151,6 @@ module CMDx
|
|
|
171
151
|
complete? || interrupted?
|
|
172
152
|
end
|
|
173
153
|
|
|
174
|
-
# @param block [Proc] Block to execute conditionally
|
|
175
|
-
#
|
|
176
|
-
# @yield [self] Executes the block if task has been executed
|
|
177
|
-
#
|
|
178
|
-
# @return [self] Returns self for method chaining
|
|
179
|
-
#
|
|
180
|
-
# @raise [ArgumentError] When no block is provided
|
|
181
|
-
#
|
|
182
|
-
# @example
|
|
183
|
-
# result.handle_executed { |r| puts "Task finished: #{r.outcome}" }
|
|
184
|
-
#
|
|
185
|
-
# @rbs () { (Result) -> void } -> self
|
|
186
|
-
def handle_executed(&)
|
|
187
|
-
raise ArgumentError, "block required" unless block_given?
|
|
188
|
-
|
|
189
|
-
yield(self) if executed?
|
|
190
|
-
self
|
|
191
|
-
end
|
|
192
|
-
|
|
193
154
|
# @raise [RuntimeError] When attempting to transition from invalid state
|
|
194
155
|
#
|
|
195
156
|
# @example
|
|
@@ -241,26 +202,6 @@ module CMDx
|
|
|
241
202
|
#
|
|
242
203
|
# @rbs () -> bool
|
|
243
204
|
define_method(:"#{s}?") { status == s }
|
|
244
|
-
|
|
245
|
-
# @param block [Proc] Block to execute conditionally
|
|
246
|
-
#
|
|
247
|
-
# @yield [self] Executes the block if result has specified status
|
|
248
|
-
#
|
|
249
|
-
# @return [self] Returns self for method chaining
|
|
250
|
-
#
|
|
251
|
-
# @raise [ArgumentError] When no block is provided
|
|
252
|
-
#
|
|
253
|
-
# @example
|
|
254
|
-
# result.handle_success { |r| puts "Task succeeded" }
|
|
255
|
-
# result.handle_failed { |r| puts "Task failed: #{r.reason}" }
|
|
256
|
-
#
|
|
257
|
-
# @rbs () { (Result) -> void } -> self
|
|
258
|
-
define_method(:"handle_#{s}") do |&block|
|
|
259
|
-
raise ArgumentError, "block required" unless block
|
|
260
|
-
|
|
261
|
-
block.call(self) if send(:"#{s}?")
|
|
262
|
-
self
|
|
263
|
-
end
|
|
264
205
|
end
|
|
265
206
|
|
|
266
207
|
# @return [Boolean] Whether the task execution was successful (not failed)
|
|
@@ -274,25 +215,6 @@ module CMDx
|
|
|
274
215
|
end
|
|
275
216
|
alias ok? good?
|
|
276
217
|
|
|
277
|
-
# @param block [Proc] Block to execute conditionally
|
|
278
|
-
#
|
|
279
|
-
# @yield [self] Executes the block if task execution was successful
|
|
280
|
-
#
|
|
281
|
-
# @return [self] Returns self for method chaining
|
|
282
|
-
#
|
|
283
|
-
# @raise [ArgumentError] When no block is provided
|
|
284
|
-
#
|
|
285
|
-
# @example
|
|
286
|
-
# result.handle_good { |r| puts "Task completed successfully" }
|
|
287
|
-
#
|
|
288
|
-
# @rbs () { (Result) -> void } -> self
|
|
289
|
-
def handle_good(&)
|
|
290
|
-
raise ArgumentError, "block required" unless block_given?
|
|
291
|
-
|
|
292
|
-
yield(self) if good?
|
|
293
|
-
self
|
|
294
|
-
end
|
|
295
|
-
|
|
296
218
|
# @return [Boolean] Whether the task execution was unsuccessful (not success)
|
|
297
219
|
#
|
|
298
220
|
# @example
|
|
@@ -303,22 +225,21 @@ module CMDx
|
|
|
303
225
|
!success?
|
|
304
226
|
end
|
|
305
227
|
|
|
306
|
-
# @
|
|
307
|
-
#
|
|
308
|
-
# @yield [self] Executes the block if task execution was unsuccessful
|
|
228
|
+
# @yield [self] Executes the block if task status or state matches
|
|
309
229
|
#
|
|
310
230
|
# @return [self] Returns self for method chaining
|
|
311
231
|
#
|
|
312
232
|
# @raise [ArgumentError] When no block is provided
|
|
313
233
|
#
|
|
314
234
|
# @example
|
|
315
|
-
# result.
|
|
235
|
+
# result.on(:bad) { |r| puts "Task had issues: #{r.reason}" }
|
|
236
|
+
# result.on(:success, :complete) { |r| puts "Task completed successfully" }
|
|
316
237
|
#
|
|
317
238
|
# @rbs () { (Result) -> void } -> self
|
|
318
|
-
def
|
|
239
|
+
def on(*states_or_statuses, &)
|
|
319
240
|
raise ArgumentError, "block required" unless block_given?
|
|
320
241
|
|
|
321
|
-
yield(self) if
|
|
242
|
+
yield(self) if states_or_statuses.any? { |s| send(:"#{s}?") }
|
|
322
243
|
self
|
|
323
244
|
end
|
|
324
245
|
|
|
@@ -326,6 +247,7 @@ module CMDx
|
|
|
326
247
|
# @param halt [Boolean] Whether to halt execution after skipping
|
|
327
248
|
# @param cause [Exception, nil] Exception that caused the skip
|
|
328
249
|
# @param metadata [Hash] Additional metadata about the skip
|
|
250
|
+
# @option metadata [Object] :* Any key-value pairs for additional metadata
|
|
329
251
|
#
|
|
330
252
|
# @raise [RuntimeError] When attempting to skip from invalid status
|
|
331
253
|
#
|
|
@@ -352,6 +274,7 @@ module CMDx
|
|
|
352
274
|
# @param halt [Boolean] Whether to halt execution after failure
|
|
353
275
|
# @param cause [Exception, nil] Exception that caused the failure
|
|
354
276
|
# @param metadata [Hash] Additional metadata about the failure
|
|
277
|
+
# @option metadata [Object] :* Any key-value pairs for additional metadata
|
|
355
278
|
#
|
|
356
279
|
# @raise [RuntimeError] When attempting to fail from invalid status
|
|
357
280
|
#
|
|
@@ -407,6 +330,7 @@ module CMDx
|
|
|
407
330
|
# @param halt [Boolean] Whether to halt execution after throwing
|
|
408
331
|
# @param cause [Exception, nil] Exception that caused the throw
|
|
409
332
|
# @param metadata [Hash] Additional metadata to merge
|
|
333
|
+
# @option metadata [Object] :* Any key-value pairs for additional metadata
|
|
410
334
|
#
|
|
411
335
|
# @raise [TypeError] When result is not a CMDx::Result instance
|
|
412
336
|
#
|
|
@@ -557,8 +481,6 @@ module CMDx
|
|
|
557
481
|
end
|
|
558
482
|
end
|
|
559
483
|
|
|
560
|
-
# @param keys [Array] Array of keys to deconstruct
|
|
561
|
-
#
|
|
562
484
|
# @return [Array] Array containing state, status, reason, cause, and metadata
|
|
563
485
|
#
|
|
564
486
|
# @example
|
|
@@ -570,8 +492,6 @@ module CMDx
|
|
|
570
492
|
[state, status, reason, cause, metadata]
|
|
571
493
|
end
|
|
572
494
|
|
|
573
|
-
# @param keys [Array] Array of keys to deconstruct
|
|
574
|
-
#
|
|
575
495
|
# @return [Hash] Hash with key-value pairs for pattern matching
|
|
576
496
|
#
|
|
577
497
|
# @example
|
data/lib/cmdx/task.rb
CHANGED
|
@@ -100,6 +100,7 @@ module CMDx
|
|
|
100
100
|
class << self
|
|
101
101
|
|
|
102
102
|
# @param options [Hash] Configuration options to merge with existing settings
|
|
103
|
+
# @option options [Object] :* Any configuration option key-value pairs
|
|
103
104
|
#
|
|
104
105
|
# @return [Hash] The merged settings hash
|
|
105
106
|
#
|
|
@@ -136,7 +137,6 @@ module CMDx
|
|
|
136
137
|
|
|
137
138
|
# @param type [Symbol] The type of registry to register with
|
|
138
139
|
# @param object [Object] The object to register
|
|
139
|
-
# @param args [Array] Additional arguments for registration
|
|
140
140
|
#
|
|
141
141
|
# @raise [RuntimeError] If the registry type is unknown
|
|
142
142
|
#
|
|
@@ -158,7 +158,6 @@ module CMDx
|
|
|
158
158
|
|
|
159
159
|
# @param type [Symbol] The type of registry to deregister from
|
|
160
160
|
# @param object [Object] The object to deregister
|
|
161
|
-
# @param args [Array] Additional arguments for deregistration
|
|
162
161
|
#
|
|
163
162
|
# @raise [RuntimeError] If the registry type is unknown
|
|
164
163
|
#
|
|
@@ -178,8 +177,6 @@ module CMDx
|
|
|
178
177
|
end
|
|
179
178
|
end
|
|
180
179
|
|
|
181
|
-
# @param args [Array] Arguments to build the attribute with
|
|
182
|
-
#
|
|
183
180
|
# @example
|
|
184
181
|
# attributes :name, :email
|
|
185
182
|
# attributes :age, type: Integer, default: 18
|
|
@@ -190,8 +187,6 @@ module CMDx
|
|
|
190
187
|
end
|
|
191
188
|
alias attribute attributes
|
|
192
189
|
|
|
193
|
-
# @param args [Array] Arguments to build the optional attribute with
|
|
194
|
-
#
|
|
195
190
|
# @example
|
|
196
191
|
# optional :description, :notes
|
|
197
192
|
# optional :priority, type: Symbol, default: :normal
|
|
@@ -201,8 +196,6 @@ module CMDx
|
|
|
201
196
|
register(:attribute, Attribute.optional(...))
|
|
202
197
|
end
|
|
203
198
|
|
|
204
|
-
# @param args [Array] Arguments to build the required attribute with
|
|
205
|
-
#
|
|
206
199
|
# @example
|
|
207
200
|
# required :name, :email
|
|
208
201
|
# required :age, type: Integer, min: 0
|
|
@@ -242,6 +235,8 @@ module CMDx
|
|
|
242
235
|
end
|
|
243
236
|
|
|
244
237
|
# @param args [Array] Arguments to pass to the task constructor
|
|
238
|
+
# @param kwargs [Hash] Keyword arguments to pass to the task constructor
|
|
239
|
+
# @option kwargs [Object] :* Any key-value pairs to pass to the task constructor
|
|
245
240
|
#
|
|
246
241
|
# @return [Result] The execution result
|
|
247
242
|
#
|
|
@@ -259,6 +254,8 @@ module CMDx
|
|
|
259
254
|
end
|
|
260
255
|
|
|
261
256
|
# @param args [Array] Arguments to pass to the task constructor
|
|
257
|
+
# @param kwargs [Hash] Keyword arguments to pass to the task constructor
|
|
258
|
+
# @option kwargs [Object] :* Any key-value pairs to pass to the task constructor
|
|
262
259
|
#
|
|
263
260
|
# @return [Result] The execution result
|
|
264
261
|
#
|
|
@@ -322,8 +319,6 @@ module CMDx
|
|
|
322
319
|
end
|
|
323
320
|
end
|
|
324
321
|
|
|
325
|
-
# @return [Hash] A hash representation of the task
|
|
326
|
-
#
|
|
327
322
|
# @option return [Integer] :index The result index
|
|
328
323
|
# @option return [String] :chain_id The chain identifier
|
|
329
324
|
# @option return [String] :type The task type ("Task" or "Workflow")
|
|
@@ -331,6 +326,8 @@ module CMDx
|
|
|
331
326
|
# @option return [String] :class The task class name
|
|
332
327
|
# @option return [String] :id The task identifier
|
|
333
328
|
#
|
|
329
|
+
# @return [Hash] A hash representation of the task
|
|
330
|
+
#
|
|
334
331
|
# @example
|
|
335
332
|
# task_hash = task.to_h
|
|
336
333
|
# puts "Task type: #{task_hash[:type]}"
|
data/lib/cmdx/utils/call.rb
CHANGED
|
@@ -17,7 +17,9 @@ module CMDx
|
|
|
17
17
|
# @param callable [Symbol, Proc, #call] The callable to invoke
|
|
18
18
|
# @param args [Array] Positional arguments to pass to the callable
|
|
19
19
|
# @param kwargs [Hash] Keyword arguments to pass to the callable
|
|
20
|
-
# @
|
|
20
|
+
# @option kwargs [Object] :* Any keyword arguments to pass to the callable
|
|
21
|
+
#
|
|
22
|
+
# @yield [Object] Block to pass to the callable
|
|
21
23
|
#
|
|
22
24
|
# @return [Object] The result of invoking the callable
|
|
23
25
|
#
|
data/lib/cmdx/utils/condition.rb
CHANGED
|
@@ -34,9 +34,6 @@ module CMDx
|
|
|
34
34
|
# @param options [Hash] Conditional options hash
|
|
35
35
|
# @option options [Object] :if Condition that must be true for evaluation to succeed
|
|
36
36
|
# @option options [Object] :unless Condition that must be false for evaluation to succeed
|
|
37
|
-
# @param args [Array] Additional arguments passed to condition evaluation
|
|
38
|
-
# @param kwargs [Hash] Additional keyword arguments passed to condition evaluation
|
|
39
|
-
# @param block [Proc, nil] Optional block passed to condition evaluation
|
|
40
37
|
#
|
|
41
38
|
# @return [Boolean] true if conditions are met, false otherwise
|
|
42
39
|
#
|
data/lib/cmdx/utils/format.rb
CHANGED
|
@@ -32,7 +32,7 @@ module CMDx
|
|
|
32
32
|
#
|
|
33
33
|
# @rbs (untyped message) -> untyped
|
|
34
34
|
def to_log(message)
|
|
35
|
-
if message.respond_to?(:to_h) && message.class.ancestors.any? { |a| a.
|
|
35
|
+
if message.respond_to?(:to_h) && message.class.ancestors.any? { |a| a.name&.start_with?("CMDx::") }
|
|
36
36
|
message.to_h
|
|
37
37
|
else
|
|
38
38
|
message
|
|
@@ -50,6 +50,7 @@ module CMDx
|
|
|
50
50
|
#
|
|
51
51
|
# @param values [Array] The forbidden values that caused the error
|
|
52
52
|
# @param options [Hash] Validation options containing custom messages
|
|
53
|
+
# @option options [Object] :* Any validation option key-value pairs
|
|
53
54
|
#
|
|
54
55
|
# @raise [ValidationError] With appropriate error message
|
|
55
56
|
def raise_of_validation_error!(values, options)
|
|
@@ -65,6 +66,7 @@ module CMDx
|
|
|
65
66
|
# @param min [Object] The minimum value of the forbidden range
|
|
66
67
|
# @param max [Object] The maximum value of the forbidden range
|
|
67
68
|
# @param options [Hash] Validation options containing custom messages
|
|
69
|
+
# @option options [Object] :* Any validation option key-value pairs
|
|
68
70
|
#
|
|
69
71
|
# @raise [ValidationError] With appropriate error message
|
|
70
72
|
def raise_within_validation_error!(min, max, options)
|
|
@@ -52,6 +52,7 @@ module CMDx
|
|
|
52
52
|
#
|
|
53
53
|
# @param values [Array] The allowed values that caused the error
|
|
54
54
|
# @param options [Hash] Validation options containing custom messages
|
|
55
|
+
# @option options [Object] :* Any validation option key-value pairs
|
|
55
56
|
#
|
|
56
57
|
# @raise [ValidationError] With appropriate error message
|
|
57
58
|
def raise_of_validation_error!(values, options)
|
|
@@ -67,6 +68,7 @@ module CMDx
|
|
|
67
68
|
# @param min [Object] The minimum value of the allowed range
|
|
68
69
|
# @param max [Object] The maximum value of the allowed range
|
|
69
70
|
# @param options [Hash] Validation options containing custom messages
|
|
71
|
+
# @option options [Object] :* Any validation option key-value pairs
|
|
70
72
|
#
|
|
71
73
|
# @raise [ValidationError] With appropriate error message
|
|
72
74
|
def raise_within_validation_error!(min, max, options)
|
|
@@ -87,6 +87,7 @@ module CMDx
|
|
|
87
87
|
# @param min [Integer] Minimum length value
|
|
88
88
|
# @param max [Integer] Maximum length value
|
|
89
89
|
# @param options [Hash] Validation options containing custom messages
|
|
90
|
+
# @option options [Object] :* Any validation option key-value pairs
|
|
90
91
|
#
|
|
91
92
|
# @raise [ValidationError] Always raised with appropriate message
|
|
92
93
|
#
|
|
@@ -103,6 +104,7 @@ module CMDx
|
|
|
103
104
|
# @param min [Integer] Minimum length value
|
|
104
105
|
# @param max [Integer] Maximum length value
|
|
105
106
|
# @param options [Hash] Validation options containing custom messages
|
|
107
|
+
# @option options [Object] :* Any validation option key-value pairs
|
|
106
108
|
#
|
|
107
109
|
# @raise [ValidationError] Always raised with appropriate message
|
|
108
110
|
#
|
|
@@ -118,6 +120,7 @@ module CMDx
|
|
|
118
120
|
#
|
|
119
121
|
# @param min [Integer] Minimum required length
|
|
120
122
|
# @param options [Hash] Validation options containing custom messages
|
|
123
|
+
# @option options [Object] :* Any validation option key-value pairs
|
|
121
124
|
#
|
|
122
125
|
# @raise [ValidationError] Always raised with appropriate message
|
|
123
126
|
#
|
|
@@ -133,6 +136,7 @@ module CMDx
|
|
|
133
136
|
#
|
|
134
137
|
# @param max [Integer] Maximum allowed length
|
|
135
138
|
# @param options [Hash] Validation options containing custom messages
|
|
139
|
+
# @option options [Object] :* Any validation option key-value pairs
|
|
136
140
|
#
|
|
137
141
|
# @raise [ValidationError] Always raised with appropriate message
|
|
138
142
|
#
|
|
@@ -148,6 +152,7 @@ module CMDx
|
|
|
148
152
|
#
|
|
149
153
|
# @param is [Integer] Required exact length
|
|
150
154
|
# @param options [Hash] Validation options containing custom messages
|
|
155
|
+
# @option options [Object] :* Any validation option key-value pairs
|
|
151
156
|
#
|
|
152
157
|
# @raise [ValidationError] Always raised with appropriate message
|
|
153
158
|
#
|
|
@@ -163,6 +168,7 @@ module CMDx
|
|
|
163
168
|
#
|
|
164
169
|
# @param is_not [Integer] Length that is not allowed
|
|
165
170
|
# @param options [Hash] Validation options containing custom messages
|
|
171
|
+
# @option options [Object] :* Any validation option key-value pairs
|
|
166
172
|
#
|
|
167
173
|
# @raise [ValidationError] Always raised with appropriate message
|
|
168
174
|
#
|
|
@@ -82,6 +82,7 @@ module CMDx
|
|
|
82
82
|
# @param min [Numeric] The minimum value of the allowed range
|
|
83
83
|
# @param max [Numeric] The maximum value of the allowed range
|
|
84
84
|
# @param options [Hash] Validation options containing custom messages
|
|
85
|
+
# @option options [Object] :* Any validation option key-value pairs
|
|
85
86
|
#
|
|
86
87
|
# @raise [ValidationError] With appropriate error message
|
|
87
88
|
#
|
|
@@ -98,6 +99,7 @@ module CMDx
|
|
|
98
99
|
# @param min [Numeric] The minimum value of the excluded range
|
|
99
100
|
# @param max [Numeric] The maximum value of the excluded range
|
|
100
101
|
# @param options [Hash] Validation options containing custom messages
|
|
102
|
+
# @option options [Object] :* Any validation option key-value pairs
|
|
101
103
|
#
|
|
102
104
|
# @raise [ValidationError] With appropriate error message
|
|
103
105
|
#
|
|
@@ -113,6 +115,7 @@ module CMDx
|
|
|
113
115
|
#
|
|
114
116
|
# @param min [Numeric] The minimum allowed value
|
|
115
117
|
# @param options [Hash] Validation options containing custom messages
|
|
118
|
+
# @option options [Object] :* Any validation option key-value pairs
|
|
116
119
|
#
|
|
117
120
|
# @raise [ValidationError] With appropriate error message
|
|
118
121
|
#
|
|
@@ -128,6 +131,7 @@ module CMDx
|
|
|
128
131
|
#
|
|
129
132
|
# @param max [Numeric] The maximum allowed value
|
|
130
133
|
# @param options [Hash] Validation options containing custom messages
|
|
134
|
+
# @option options [Object] :* Any validation option key-value pairs
|
|
131
135
|
#
|
|
132
136
|
# @raise [ValidationError] With appropriate error message
|
|
133
137
|
#
|
|
@@ -143,6 +147,7 @@ module CMDx
|
|
|
143
147
|
#
|
|
144
148
|
# @param is [Numeric] The exact value that was expected
|
|
145
149
|
# @param options [Hash] Validation options containing custom messages
|
|
150
|
+
# @option options [Object] :* Any validation option key-value pairs
|
|
146
151
|
#
|
|
147
152
|
# @raise [ValidationError] With appropriate error message
|
|
148
153
|
#
|
|
@@ -158,6 +163,7 @@ module CMDx
|
|
|
158
163
|
#
|
|
159
164
|
# @param is_not [Numeric] The value that was not allowed
|
|
160
165
|
# @param options [Hash] Validation options containing custom messages
|
|
166
|
+
# @option options [Object] :* Any validation option key-value pairs
|
|
161
167
|
#
|
|
162
168
|
# @raise [ValidationError] With appropriate error message
|
|
163
169
|
#
|
data/lib/cmdx/version.rb
CHANGED
|
@@ -22,13 +22,14 @@ module Cmdx
|
|
|
22
22
|
#
|
|
23
23
|
# @return [void]
|
|
24
24
|
#
|
|
25
|
-
# @example
|
|
26
|
-
#
|
|
27
|
-
#
|
|
25
|
+
# @example Copy default (English) locale file
|
|
26
|
+
# generator = Cmdx::LocaleGenerator.new(["en"])
|
|
27
|
+
# generator.copy_locale_files
|
|
28
28
|
# # => Creates config/locales/en.yml
|
|
29
29
|
#
|
|
30
|
-
#
|
|
31
|
-
#
|
|
30
|
+
# @example Copy Spanish locale file
|
|
31
|
+
# generator = Cmdx::LocaleGenerator.new(["es"])
|
|
32
|
+
# generator.copy_locale_files
|
|
32
33
|
# # => Creates config/locales/es.yml
|
|
33
34
|
def copy_locale_files
|
|
34
35
|
copy_file("#{locale}.yml", "config/locales/#{locale}.yml")
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: cmdx
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.12.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Juan Gomez
|
|
@@ -205,6 +205,20 @@ dependencies:
|
|
|
205
205
|
- - ">="
|
|
206
206
|
- !ruby/object:Gem::Version
|
|
207
207
|
version: '0'
|
|
208
|
+
- !ruby/object:Gem::Dependency
|
|
209
|
+
name: yard-lint
|
|
210
|
+
requirement: !ruby/object:Gem::Requirement
|
|
211
|
+
requirements:
|
|
212
|
+
- - ">="
|
|
213
|
+
- !ruby/object:Gem::Version
|
|
214
|
+
version: '0'
|
|
215
|
+
type: :development
|
|
216
|
+
prerelease: false
|
|
217
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
218
|
+
requirements:
|
|
219
|
+
- - ">="
|
|
220
|
+
- !ruby/object:Gem::Version
|
|
221
|
+
version: '0'
|
|
208
222
|
description: CMDx is a framework for building maintainable business processes.
|
|
209
223
|
email:
|
|
210
224
|
- drexed@users.noreply.github.com
|
|
@@ -222,6 +236,7 @@ files:
|
|
|
222
236
|
- ".rspec"
|
|
223
237
|
- ".rubocop.yml"
|
|
224
238
|
- ".ruby-version"
|
|
239
|
+
- ".yard-lint.yml"
|
|
225
240
|
- ".yardopts"
|
|
226
241
|
- CHANGELOG.md
|
|
227
242
|
- CODE_OF_CONDUCT.md
|
|
@@ -259,8 +274,12 @@ files:
|
|
|
259
274
|
- docs/stylesheets/extra.css
|
|
260
275
|
- docs/tips_and_tricks.md
|
|
261
276
|
- docs/workflows.md
|
|
277
|
+
- examples/active_record_database_transaction.md
|
|
262
278
|
- examples/active_record_query_tagging.md
|
|
279
|
+
- examples/flipper_feature_flags.md
|
|
263
280
|
- examples/paper_trail_whatdunnit.md
|
|
281
|
+
- examples/redis_idempotency.md
|
|
282
|
+
- examples/sentry_error_tracking.md
|
|
264
283
|
- examples/sidekiq_async_execution.md
|
|
265
284
|
- examples/stoplight_circuit_breaker.md
|
|
266
285
|
- lib/cmdx.rb
|