cmdx 1.20.0 → 1.21.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/CHANGELOG.md +13 -0
- data/lib/cmdx/chain.rb +1 -1
- data/lib/cmdx/configuration.rb +12 -0
- data/lib/cmdx/context.rb +2 -2
- data/lib/cmdx/executor.rb +5 -1
- data/lib/cmdx/middlewares/runtime.rb +18 -3
- data/lib/cmdx/pipeline.rb +1 -1
- data/lib/cmdx/result.rb +64 -8
- data/lib/cmdx/settings.rb +4 -0
- data/lib/cmdx/task.rb +9 -2
- data/lib/cmdx/version.rb +1 -1
- data/lib/cmdx/workflow.rb +17 -0
- data/lib/generators/cmdx/templates/install.rb +9 -5
- data/lib/locales/af.yml +2 -0
- data/lib/locales/ar.yml +2 -0
- data/lib/locales/az.yml +2 -0
- data/lib/locales/be.yml +2 -0
- data/lib/locales/bg.yml +2 -0
- data/lib/locales/bn.yml +2 -0
- data/lib/locales/bs.yml +2 -0
- data/lib/locales/ca.yml +2 -0
- data/lib/locales/cnr.yml +2 -0
- data/lib/locales/cs.yml +2 -0
- data/lib/locales/cy.yml +2 -0
- data/lib/locales/da.yml +2 -0
- data/lib/locales/de.yml +2 -0
- data/lib/locales/dz.yml +2 -0
- data/lib/locales/el.yml +2 -0
- data/lib/locales/en.yml +2 -0
- data/lib/locales/eo.yml +2 -0
- data/lib/locales/es.yml +2 -0
- data/lib/locales/et.yml +2 -0
- data/lib/locales/eu.yml +2 -0
- data/lib/locales/fa.yml +2 -0
- data/lib/locales/fi.yml +2 -0
- data/lib/locales/fr.yml +2 -0
- data/lib/locales/fy.yml +2 -0
- data/lib/locales/gd.yml +2 -0
- data/lib/locales/gl.yml +2 -0
- data/lib/locales/he.yml +2 -0
- data/lib/locales/hi.yml +2 -0
- data/lib/locales/hr.yml +2 -0
- data/lib/locales/hu.yml +2 -0
- data/lib/locales/hy.yml +2 -0
- data/lib/locales/id.yml +2 -0
- data/lib/locales/is.yml +2 -0
- data/lib/locales/it.yml +2 -0
- data/lib/locales/ja.yml +2 -0
- data/lib/locales/ka.yml +2 -0
- data/lib/locales/kk.yml +2 -0
- data/lib/locales/km.yml +2 -0
- data/lib/locales/kn.yml +2 -0
- data/lib/locales/ko.yml +2 -0
- data/lib/locales/lb.yml +2 -0
- data/lib/locales/lo.yml +2 -0
- data/lib/locales/lt.yml +2 -0
- data/lib/locales/lv.yml +2 -0
- data/lib/locales/mg.yml +2 -0
- data/lib/locales/mk.yml +2 -0
- data/lib/locales/ml.yml +2 -0
- data/lib/locales/mn.yml +2 -0
- data/lib/locales/mr-IN.yml +2 -0
- data/lib/locales/ms.yml +2 -0
- data/lib/locales/nb.yml +2 -0
- data/lib/locales/ne.yml +2 -0
- data/lib/locales/nl.yml +2 -0
- data/lib/locales/nn.yml +2 -0
- data/lib/locales/oc.yml +2 -0
- data/lib/locales/or.yml +2 -0
- data/lib/locales/pa.yml +2 -0
- data/lib/locales/pl.yml +2 -0
- data/lib/locales/pt.yml +2 -0
- data/lib/locales/rm.yml +2 -0
- data/lib/locales/ro.yml +2 -0
- data/lib/locales/ru.yml +2 -0
- data/lib/locales/sc.yml +2 -0
- data/lib/locales/sk.yml +2 -0
- data/lib/locales/sl.yml +2 -0
- data/lib/locales/sq.yml +2 -0
- data/lib/locales/sr.yml +2 -0
- data/lib/locales/st.yml +2 -0
- data/lib/locales/sv.yml +2 -0
- data/lib/locales/sw.yml +2 -0
- data/lib/locales/ta.yml +2 -0
- data/lib/locales/te.yml +2 -0
- data/lib/locales/th.yml +2 -0
- data/lib/locales/tl.yml +2 -0
- data/lib/locales/tr.yml +2 -0
- data/lib/locales/tt.yml +2 -0
- data/lib/locales/ug.yml +2 -0
- data/lib/locales/uk.yml +2 -0
- data/lib/locales/ur.yml +2 -0
- data/lib/locales/uz.yml +2 -0
- data/lib/locales/vi.yml +2 -0
- data/lib/locales/wo.yml +2 -0
- data/lib/locales/zh-CN.yml +2 -0
- data/lib/locales/zh-HK.yml +2 -0
- data/lib/locales/zh-TW.yml +2 -0
- data/lib/locales/zh-YUE.yml +2 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1acff12a85519d3546d8c2c6b8d9a8fc6330e731826a9a4a359907631e7afa82
|
|
4
|
+
data.tar.gz: 69c814dc115c70dc36ab02e7462d00a5b802490d39b7f4bc1fb2c9e5c666c55e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f2bc1eb34789f888bffc84b9ebb65252fc23ea8d598465c9ff853670ab44c9e640988b2a528ed97ff53cc1774a26e35a87706a9056aa7fc55f6604e73540cb29
|
|
7
|
+
data.tar.gz: 5c7af44bda7a2d7371c8f62183dde2195bf9b27382c65c379bc8bfd94321d7b3ab61ad41888a9a1dad57c4e606de843f4d479581cc2cea20aeb3fb8996afcd52
|
data/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,19 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
|
6
6
|
|
|
7
7
|
## [UNRELEASED]
|
|
8
8
|
|
|
9
|
+
## [1.21.0] - 2026-04-09
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
- Add `strict` option to `Result#skip!` and `Result#fail!` to bypass breakpoint halting in `execute!`
|
|
13
|
+
- Add `dump_context` global/local setting to include `context` in `Task#to_h`
|
|
14
|
+
- Add `Result#success!` for annotating successful results
|
|
15
|
+
- Add `started_at` and `ended_at` to runtime middleware payload
|
|
16
|
+
- Add `keys`, `values`, `each`, `each_key`, `each_value` methods to context
|
|
17
|
+
- Add `subtasks` to returns tasks defined in a workflow
|
|
18
|
+
|
|
19
|
+
### Changed
|
|
20
|
+
- Move `faults.unspecified` locale key to `reasons.unspecified`
|
|
21
|
+
|
|
9
22
|
## [1.20.0] - 2026-03-12
|
|
10
23
|
|
|
11
24
|
### Added
|
data/lib/cmdx/chain.rb
CHANGED
|
@@ -32,7 +32,7 @@ module CMDx
|
|
|
32
32
|
attr_reader :results
|
|
33
33
|
|
|
34
34
|
def_delegators :results, :first, :last, :size
|
|
35
|
-
def_delegators :first, :state, :status, :outcome
|
|
35
|
+
def_delegators :first, :state, :status, :outcome
|
|
36
36
|
|
|
37
37
|
# Creates a new chain with a unique identifier and empty results collection.
|
|
38
38
|
#
|
data/lib/cmdx/configuration.rb
CHANGED
|
@@ -123,6 +123,16 @@ module CMDx
|
|
|
123
123
|
# @rbs @rollback_on: Array[String]
|
|
124
124
|
attr_accessor :rollback_on
|
|
125
125
|
|
|
126
|
+
# Returns whether to include context data in hash representation output.
|
|
127
|
+
#
|
|
128
|
+
# @return [Boolean] true if context should be included (default: false)
|
|
129
|
+
#
|
|
130
|
+
# @example
|
|
131
|
+
# config.dump_context = true
|
|
132
|
+
#
|
|
133
|
+
# @rbs @dump_context: bool
|
|
134
|
+
attr_accessor :dump_context
|
|
135
|
+
|
|
126
136
|
# Returns whether to freeze task results after execution.
|
|
127
137
|
# Set to false in test environments to allow stubbing on result objects.
|
|
128
138
|
#
|
|
@@ -167,6 +177,7 @@ module CMDx
|
|
|
167
177
|
@task_breakpoints = DEFAULT_BREAKPOINTS
|
|
168
178
|
@workflow_breakpoints = DEFAULT_BREAKPOINTS
|
|
169
179
|
@rollback_on = DEFAULT_ROLLPOINTS
|
|
180
|
+
@dump_context = false
|
|
170
181
|
@freeze_results = true
|
|
171
182
|
@default_locale = "en"
|
|
172
183
|
|
|
@@ -206,6 +217,7 @@ module CMDx
|
|
|
206
217
|
backtrace: @backtrace,
|
|
207
218
|
backtrace_cleaner: @backtrace_cleaner,
|
|
208
219
|
exception_handler: @exception_handler,
|
|
220
|
+
dump_context: @dump_context,
|
|
209
221
|
logger: @logger
|
|
210
222
|
}
|
|
211
223
|
end
|
data/lib/cmdx/context.rb
CHANGED
|
@@ -22,7 +22,7 @@ module CMDx
|
|
|
22
22
|
attr_reader :table
|
|
23
23
|
alias to_h table
|
|
24
24
|
|
|
25
|
-
def_delegators :table, :each, :map
|
|
25
|
+
def_delegators :table, :keys, :values, :each, :each_key, :each_value, :map
|
|
26
26
|
|
|
27
27
|
# Creates a new Context instance from the given arguments.
|
|
28
28
|
#
|
|
@@ -214,7 +214,7 @@ module CMDx
|
|
|
214
214
|
#
|
|
215
215
|
# @rbs (untyped other) -> bool
|
|
216
216
|
def eql?(other)
|
|
217
|
-
other.is_a?(self.class) && (
|
|
217
|
+
other.is_a?(self.class) && (table == other.to_h)
|
|
218
218
|
end
|
|
219
219
|
alias == eql?
|
|
220
220
|
|
data/lib/cmdx/executor.rb
CHANGED
|
@@ -135,6 +135,7 @@ module CMDx
|
|
|
135
135
|
protected
|
|
136
136
|
|
|
137
137
|
# Determines if execution should halt based on breakpoint configuration.
|
|
138
|
+
# Returns false when the result was created with +strict: false+.
|
|
138
139
|
#
|
|
139
140
|
# @param exception [Exception] The exception that occurred
|
|
140
141
|
#
|
|
@@ -142,6 +143,8 @@ module CMDx
|
|
|
142
143
|
#
|
|
143
144
|
# @rbs (Exception exception) -> bool
|
|
144
145
|
def halt_execution?(exception)
|
|
146
|
+
return false unless exception.result.strict?
|
|
147
|
+
|
|
145
148
|
@halt_statuses ||= Utils::Normalize.statuses(
|
|
146
149
|
task.class.settings.breakpoints ||
|
|
147
150
|
task.class.settings.task_breakpoints
|
|
@@ -229,13 +232,14 @@ module CMDx
|
|
|
229
232
|
end
|
|
230
233
|
|
|
231
234
|
# Executes the main task logic.
|
|
235
|
+
# Wraps task.work in catch(:cmdx_halt) so that success! can halt early.
|
|
232
236
|
#
|
|
233
237
|
# @rbs () -> void
|
|
234
238
|
def execution!
|
|
235
239
|
invoke_callbacks(:before_execution)
|
|
236
240
|
|
|
237
241
|
result.executing!
|
|
238
|
-
task.work
|
|
242
|
+
catch(:cmdx_halt) { task.work }
|
|
239
243
|
end
|
|
240
244
|
|
|
241
245
|
# Verifies that all declared returns are present in the context after execution.
|
|
@@ -11,7 +11,8 @@ module CMDx
|
|
|
11
11
|
|
|
12
12
|
extend self
|
|
13
13
|
|
|
14
|
-
# Middleware entry point that measures task execution runtime
|
|
14
|
+
# Middleware entry point that measures task execution runtime and
|
|
15
|
+
# task execution start and end times.
|
|
15
16
|
#
|
|
16
17
|
# Evaluates the condition from options and measures execution time
|
|
17
18
|
# if enabled. Uses monotonic clock for precise timing measurements
|
|
@@ -35,11 +36,16 @@ module CMDx
|
|
|
35
36
|
#
|
|
36
37
|
# @rbs (Task task, **untyped options) { () -> untyped } -> untyped
|
|
37
38
|
def call(task, **options)
|
|
39
|
+
unow = utc_time
|
|
40
|
+
mnow = monotonic_time
|
|
38
41
|
return yield unless Utils::Condition.evaluate(task, options)
|
|
39
42
|
|
|
40
|
-
now = monotonic_time
|
|
41
43
|
result = yield
|
|
42
|
-
task.result.metadata
|
|
44
|
+
task.result.metadata.merge!(
|
|
45
|
+
runtime: monotonic_time - mnow,
|
|
46
|
+
ended_at: utc_time,
|
|
47
|
+
started_at: unow
|
|
48
|
+
)
|
|
43
49
|
result
|
|
44
50
|
end
|
|
45
51
|
|
|
@@ -57,6 +63,15 @@ module CMDx
|
|
|
57
63
|
Process.clock_gettime(Process::CLOCK_MONOTONIC, :millisecond)
|
|
58
64
|
end
|
|
59
65
|
|
|
66
|
+
# Gets the current UTC time in ISO 8601 format.
|
|
67
|
+
#
|
|
68
|
+
# @return [String] Current UTC time in ISO 8601 format
|
|
69
|
+
#
|
|
70
|
+
# @rbs () -> String
|
|
71
|
+
def utc_time
|
|
72
|
+
Time.now.utc.iso8601
|
|
73
|
+
end
|
|
74
|
+
|
|
60
75
|
end
|
|
61
76
|
end
|
|
62
77
|
end
|
data/lib/cmdx/pipeline.rb
CHANGED
data/lib/cmdx/result.rb
CHANGED
|
@@ -109,6 +109,18 @@ module CMDx
|
|
|
109
109
|
# @rbs @retries: Integer
|
|
110
110
|
attr_accessor :retries
|
|
111
111
|
|
|
112
|
+
# Returns whether this result is strict.
|
|
113
|
+
# When false, {CMDx::Executor#halt_execution?} returns false
|
|
114
|
+
# regardless of the task's breakpoint settings.
|
|
115
|
+
#
|
|
116
|
+
# @return [Boolean] Whether the result is strict
|
|
117
|
+
#
|
|
118
|
+
# @example
|
|
119
|
+
# result.strict? # => true
|
|
120
|
+
#
|
|
121
|
+
# @rbs @strict: bool
|
|
122
|
+
attr_reader :strict
|
|
123
|
+
|
|
112
124
|
# Returns whether the result has been rolled back.
|
|
113
125
|
#
|
|
114
126
|
# @return [Boolean] Whether the result has been rolled back
|
|
@@ -143,6 +155,7 @@ module CMDx
|
|
|
143
155
|
@reason = nil
|
|
144
156
|
@cause = nil
|
|
145
157
|
@retries = 0
|
|
158
|
+
@strict = true
|
|
146
159
|
@rolled_back = false
|
|
147
160
|
end
|
|
148
161
|
|
|
@@ -269,9 +282,36 @@ module CMDx
|
|
|
269
282
|
self
|
|
270
283
|
end
|
|
271
284
|
|
|
285
|
+
# Sets a reason and optional metadata on a successful result without
|
|
286
|
+
# changing its state or status. Useful for annotating why a task succeeded.
|
|
287
|
+
# When halt is true, uses throw/catch to exit the work method early.
|
|
288
|
+
#
|
|
289
|
+
# @param reason [String, nil] Reason or note for the success
|
|
290
|
+
# @param halt [Boolean] Whether to halt execution after success
|
|
291
|
+
# @param metadata [Hash] Additional metadata about the success
|
|
292
|
+
# @option metadata [Object] :* Any key-value pairs for additional metadata
|
|
293
|
+
#
|
|
294
|
+
# @raise [RuntimeError] When status is not success
|
|
295
|
+
#
|
|
296
|
+
# @example
|
|
297
|
+
# result.success!("Created 42 records")
|
|
298
|
+
# result.success!("Imported", halt: false, rows: 100)
|
|
299
|
+
#
|
|
300
|
+
# @rbs (?String? reason, halt: bool, **untyped metadata) -> void
|
|
301
|
+
def success!(reason = nil, halt: true, **metadata)
|
|
302
|
+
raise "can only be used while #{SUCCESS}" unless success?
|
|
303
|
+
|
|
304
|
+
@reason = reason
|
|
305
|
+
@metadata = metadata
|
|
306
|
+
|
|
307
|
+
throw(:cmdx_halt) if halt
|
|
308
|
+
end
|
|
309
|
+
|
|
272
310
|
# @param reason [String, nil] Reason for skipping the task
|
|
273
311
|
# @param halt [Boolean] Whether to halt execution after skipping
|
|
274
312
|
# @param cause [Exception, nil] Exception that caused the skip
|
|
313
|
+
# @param strict [Boolean] Whether this skip is strict (default: true).
|
|
314
|
+
# When false, {CMDx::Executor#halt_execution?} returns false regardless of task settings.
|
|
275
315
|
# @param metadata [Hash] Additional metadata about the skip
|
|
276
316
|
# @option metadata [Object] :* Any key-value pairs for additional metadata
|
|
277
317
|
#
|
|
@@ -280,17 +320,19 @@ module CMDx
|
|
|
280
320
|
# @example
|
|
281
321
|
# result.skip!("Dependencies not met", cause: dependency_error)
|
|
282
322
|
# result.skip!("Already processed", halt: false)
|
|
323
|
+
# result.skip!("Optional step", strict: false)
|
|
283
324
|
#
|
|
284
|
-
# @rbs (?String? reason, halt: bool, cause: Exception?, **untyped metadata) -> void
|
|
285
|
-
def skip!(reason = nil, halt: true, cause: nil, **metadata)
|
|
325
|
+
# @rbs (?String? reason, halt: bool, cause: Exception?, strict: bool, **untyped metadata) -> void
|
|
326
|
+
def skip!(reason = nil, halt: true, cause: nil, strict: true, **metadata)
|
|
286
327
|
return if skipped?
|
|
287
328
|
|
|
288
329
|
raise "can only transition to #{SKIPPED} from #{SUCCESS}" unless success?
|
|
289
330
|
|
|
290
331
|
@state = INTERRUPTED
|
|
291
332
|
@status = SKIPPED
|
|
292
|
-
@reason = reason || Locale.t("cmdx.
|
|
333
|
+
@reason = reason || Locale.t("cmdx.reasons.unspecified")
|
|
293
334
|
@cause = cause
|
|
335
|
+
@strict = strict
|
|
294
336
|
@metadata = metadata
|
|
295
337
|
|
|
296
338
|
halt! if halt
|
|
@@ -299,6 +341,8 @@ module CMDx
|
|
|
299
341
|
# @param reason [String, nil] Reason for task failure
|
|
300
342
|
# @param halt [Boolean] Whether to halt execution after failure
|
|
301
343
|
# @param cause [Exception, nil] Exception that caused the failure
|
|
344
|
+
# @param strict [Boolean] Whether this failure is strict (default: true).
|
|
345
|
+
# When false, {CMDx::Executor#halt_execution?} returns false regardless of task settings.
|
|
302
346
|
# @param metadata [Hash] Additional metadata about the failure
|
|
303
347
|
# @option metadata [Object] :* Any key-value pairs for additional metadata
|
|
304
348
|
#
|
|
@@ -307,17 +351,19 @@ module CMDx
|
|
|
307
351
|
# @example
|
|
308
352
|
# result.fail!("Validation failed", cause: validation_error)
|
|
309
353
|
# result.fail!("Network timeout", halt: false, timeout: 30)
|
|
354
|
+
# result.fail!("Soft failure", strict: false)
|
|
310
355
|
#
|
|
311
|
-
# @rbs (?String? reason, halt: bool, cause: Exception?, **untyped metadata) -> void
|
|
312
|
-
def fail!(reason = nil, halt: true, cause: nil, **metadata)
|
|
356
|
+
# @rbs (?String? reason, halt: bool, cause: Exception?, strict: bool, **untyped metadata) -> void
|
|
357
|
+
def fail!(reason = nil, halt: true, cause: nil, strict: true, **metadata)
|
|
313
358
|
return if failed?
|
|
314
359
|
|
|
315
360
|
raise "can only transition to #{FAILED} from #{SUCCESS}" unless success?
|
|
316
361
|
|
|
317
362
|
@state = INTERRUPTED
|
|
318
363
|
@status = FAILED
|
|
319
|
-
@reason = reason || Locale.t("cmdx.
|
|
364
|
+
@reason = reason || Locale.t("cmdx.reasons.unspecified")
|
|
320
365
|
@cause = cause
|
|
366
|
+
@strict = strict
|
|
321
367
|
@metadata = metadata
|
|
322
368
|
|
|
323
369
|
halt! if halt
|
|
@@ -464,6 +510,16 @@ module CMDx
|
|
|
464
510
|
retries.positive?
|
|
465
511
|
end
|
|
466
512
|
|
|
513
|
+
# @return [Boolean] Whether the result is strict
|
|
514
|
+
#
|
|
515
|
+
# @example
|
|
516
|
+
# result.strict? # => true
|
|
517
|
+
#
|
|
518
|
+
# @rbs () -> bool
|
|
519
|
+
def strict?
|
|
520
|
+
!!@strict
|
|
521
|
+
end
|
|
522
|
+
|
|
467
523
|
# @return [Boolean] Whether the result has been rolled back
|
|
468
524
|
#
|
|
469
525
|
# @example
|
|
@@ -499,7 +555,7 @@ module CMDx
|
|
|
499
555
|
#
|
|
500
556
|
# @example
|
|
501
557
|
# result.to_h
|
|
502
|
-
# # => {state: "complete", status: "success", outcome: "success", metadata: {}}
|
|
558
|
+
# # => {state: "complete", status: "success", outcome: "success", reason: "Unspecified", metadata: {}}
|
|
503
559
|
#
|
|
504
560
|
# @rbs () -> Hash[Symbol, untyped]
|
|
505
561
|
def to_h
|
|
@@ -507,10 +563,10 @@ module CMDx
|
|
|
507
563
|
state:,
|
|
508
564
|
status:,
|
|
509
565
|
outcome:,
|
|
566
|
+
reason:,
|
|
510
567
|
metadata:
|
|
511
568
|
).tap do |hash|
|
|
512
569
|
if interrupted?
|
|
513
|
-
hash[:reason] = reason
|
|
514
570
|
hash[:cause] = cause
|
|
515
571
|
hash[:rolled_back] = rolled_back?
|
|
516
572
|
end
|
data/lib/cmdx/settings.rb
CHANGED
|
@@ -113,6 +113,10 @@ module CMDx
|
|
|
113
113
|
# @return [Boolean] true if backtraces should be logged
|
|
114
114
|
delegate_to_configuration :backtrace
|
|
115
115
|
|
|
116
|
+
# @!attribute [rw] dump_context
|
|
117
|
+
# @return [Boolean] true if context should be included in Task#to_h
|
|
118
|
+
delegate_to_configuration :dump_context
|
|
119
|
+
|
|
116
120
|
# @!attribute [rw] rollback_on
|
|
117
121
|
# @return [Array<String>] Statuses that trigger rollback
|
|
118
122
|
delegate_to_configuration :rollback_on
|
data/lib/cmdx/task.rb
CHANGED
|
@@ -70,7 +70,7 @@ module CMDx
|
|
|
70
70
|
# @rbs @chain: Chain
|
|
71
71
|
attr_reader :chain
|
|
72
72
|
|
|
73
|
-
def_delegators :result, :skip!, :fail!, :throw!
|
|
73
|
+
def_delegators :result, :success!, :skip!, :fail!, :throw!
|
|
74
74
|
def_delegators :chain, :dry_run?
|
|
75
75
|
|
|
76
76
|
# @param context [Hash, Context, nil] The initial context for the task
|
|
@@ -376,6 +376,7 @@ module CMDx
|
|
|
376
376
|
# @option return [Array<Symbol>] :tags The task tags
|
|
377
377
|
# @option return [String] :class The task class name
|
|
378
378
|
# @option return [String] :id The task identifier
|
|
379
|
+
# @option return [Hash] :context The task context (when dump_context is true)
|
|
379
380
|
#
|
|
380
381
|
# @return [Hash] A hash representation of the task
|
|
381
382
|
#
|
|
@@ -394,7 +395,13 @@ module CMDx
|
|
|
394
395
|
id:,
|
|
395
396
|
dry_run: dry_run?,
|
|
396
397
|
tags: self.class.settings.tags
|
|
397
|
-
}
|
|
398
|
+
}.tap do |hash|
|
|
399
|
+
if self.class.settings.dump_context
|
|
400
|
+
# Large context can make dumps and logs very noisy,
|
|
401
|
+
# so only include it if explicitly enabled
|
|
402
|
+
hash[:context] = context.to_h
|
|
403
|
+
end
|
|
404
|
+
end
|
|
398
405
|
end
|
|
399
406
|
|
|
400
407
|
# @return [String] A string representation of the task
|
data/lib/cmdx/version.rb
CHANGED
data/lib/cmdx/workflow.rb
CHANGED
|
@@ -73,6 +73,23 @@ module CMDx
|
|
|
73
73
|
end
|
|
74
74
|
alias task tasks
|
|
75
75
|
|
|
76
|
+
# Returns all tasks in the pipeline.
|
|
77
|
+
#
|
|
78
|
+
# @return [Array<Class>] Array of task classes
|
|
79
|
+
#
|
|
80
|
+
# @example
|
|
81
|
+
# class MyWorkflow
|
|
82
|
+
# include CMDx::Workflow
|
|
83
|
+
# task Task1
|
|
84
|
+
# task Task2
|
|
85
|
+
# puts subtasks.size # => 2
|
|
86
|
+
# end
|
|
87
|
+
#
|
|
88
|
+
# @rbs () -> Array[Class]
|
|
89
|
+
def subtasks
|
|
90
|
+
pipeline.flat_map(&:tasks)
|
|
91
|
+
end
|
|
92
|
+
|
|
76
93
|
end
|
|
77
94
|
|
|
78
95
|
# Represents a group of tasks with shared execution options.
|
|
@@ -10,7 +10,7 @@ CMDx.configure do |config|
|
|
|
10
10
|
|
|
11
11
|
# Workflow breakpoint configuration - controls when workflows stop execution
|
|
12
12
|
# When a task returns these statuses, subsequent workflow tasks won't execute
|
|
13
|
-
# See https://github.com/drexed/cmdx/blob/main/docs/
|
|
13
|
+
# See https://github.com/drexed/cmdx/blob/main/docs/workflows.md for more details
|
|
14
14
|
#
|
|
15
15
|
# Available statuses: "success", "skipped", "failed"
|
|
16
16
|
# If set to an empty array, workflow will never halt
|
|
@@ -44,18 +44,22 @@ CMDx.configure do |config|
|
|
|
44
44
|
# config.default_locale = "en"
|
|
45
45
|
|
|
46
46
|
# Backtrace configuration - controls whether to log backtraces on faults and exceptions
|
|
47
|
-
# https://github.com/drexed/cmdx/blob/main/docs/
|
|
47
|
+
# https://github.com/drexed/cmdx/blob/main/docs/configuration.md#backtraces
|
|
48
48
|
# config.backtrace = false
|
|
49
49
|
# config.backtrace_cleaner = nil
|
|
50
50
|
|
|
51
51
|
# Exception handler configuration - called when non-fault exceptions are raised
|
|
52
|
-
# https://github.com/drexed/cmdx/blob/main/docs/
|
|
52
|
+
# https://github.com/drexed/cmdx/blob/main/docs/configuration.md#exception-handlers
|
|
53
53
|
# config.exception_handler = nil
|
|
54
54
|
|
|
55
|
+
# Dump context configuration - include context data in hash representation output
|
|
56
|
+
# https://github.com/drexed/cmdx/blob/main/docs/configuration.md#dump-context
|
|
57
|
+
# config.dump_context = false
|
|
58
|
+
|
|
55
59
|
# Additional global configurations - automatically applied to all tasks
|
|
56
60
|
#
|
|
57
61
|
# Middlewares - https://github.com/drexed/cmdx/blob/main/docs/middlewares.md
|
|
58
62
|
# Callbacks - https://github.com/drexed/cmdx/blob/main/docs/callbacks.md
|
|
59
|
-
# Coercions - https://github.com/drexed/cmdx/blob/main/docs/coercions.md
|
|
60
|
-
# Validations - https://github.com/drexed/cmdx/blob/main/docs/validations.md
|
|
63
|
+
# Coercions - https://github.com/drexed/cmdx/blob/main/docs/attributes/coercions.md
|
|
64
|
+
# Validations - https://github.com/drexed/cmdx/blob/main/docs/attributes/validations.md
|
|
61
65
|
end
|
data/lib/locales/af.yml
CHANGED
data/lib/locales/ar.yml
CHANGED
data/lib/locales/az.yml
CHANGED
data/lib/locales/be.yml
CHANGED
data/lib/locales/bg.yml
CHANGED
data/lib/locales/bn.yml
CHANGED
data/lib/locales/bs.yml
CHANGED
data/lib/locales/ca.yml
CHANGED
data/lib/locales/cnr.yml
CHANGED
data/lib/locales/cs.yml
CHANGED
data/lib/locales/cy.yml
CHANGED
data/lib/locales/da.yml
CHANGED
data/lib/locales/de.yml
CHANGED
data/lib/locales/dz.yml
CHANGED
data/lib/locales/el.yml
CHANGED
data/lib/locales/en.yml
CHANGED
data/lib/locales/eo.yml
CHANGED
data/lib/locales/es.yml
CHANGED
data/lib/locales/et.yml
CHANGED
data/lib/locales/eu.yml
CHANGED