cmdx 1.5.0 → 1.5.2

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: de49105a37f479ac8172f6329536b45a976adbb4e09c43b9351e329dbf662760
4
- data.tar.gz: 7b100f2619d36ae0ac287c108bbab114168d87528beb1751951ac1282dbc37d3
3
+ metadata.gz: 14a2616a171c3c514fbc553369936eac48fe2fd3d8e406cc4780ee39a483637f
4
+ data.tar.gz: 28d973a4973c4f2dc5e3acf1c1a09d4a0e0fbe158bc2f3553a5722acb9490051
5
5
  SHA512:
6
- metadata.gz: becbfc6dcc4657b16697559c91bac79a2416610655f2831cef74745d30720ac6e0f64991b442229384c8c98259f3b9dc0df706b60c988c01462a8a02eb8ee097
7
- data.tar.gz: e0dc0122625d710048768d0a31b39a1081ef800206e331f7e842b483c4639108177dbe83a6e1b47cbd08328ddfc5899e5d5b682ce65ec90287035b8e17a7d8f3
6
+ metadata.gz: 363225923cd389ddca29f5580321ef3fb3efe863b08480a31b505f67ca08db260695e752631f0b58912421679bc43b52bd679c6e3a0441a8d54628f7b09d855c
7
+ data.tar.gz: 7d479a75b0e048e9eb7385ce31b7f3bc10512856ba9fe95b34bde5b4a833822787a087d0420a6020830fc322846d72e80604ff3706d25795cc486707d1c31726
@@ -58,4 +58,3 @@ business logic within service/command objects.
58
58
  - Keep comments up-to-date with code changes
59
59
  - Keep documentation consistent
60
60
  - Update CHANGELOG.md with any changes
61
-
data/CHANGELOG.md CHANGED
@@ -6,6 +6,18 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
 
7
7
  ## [TODO]
8
8
 
9
+ ## [1.5.2] - 2025-08-22
10
+
11
+ ### Changes
12
+ - Rename the workflow `execution_groups` attribute to `pipeline`
13
+
14
+ ## [1.5.1] - 2025-08-21
15
+
16
+ ### Changes
17
+ - Prefix I18n with `::` to play nice with `CMDx::I18n`
18
+ - Safe navigate length and numeric validators
19
+ - Update railtie file path points to correct directory
20
+
9
21
  ## [1.5.0] - 2025-08-21
10
22
 
11
23
  ### Changes
data/LLM.md CHANGED
@@ -44,11 +44,20 @@ Globally these settings are initialized with sensible defaults.
44
44
 
45
45
  ### Breakpoints
46
46
 
47
- Breakpoints control when `execute!` raises faults.
47
+ Raise `CMDx::Fault` when a task called with `execute!` returns a matching status.
48
48
 
49
49
  ```ruby
50
50
  CMDx.configure do |config|
51
- config.task_breakpoints = "skipped"
51
+ # String or Array[String]
52
+ config.task_breakpoints = "failed"
53
+ end
54
+ ```
55
+
56
+ Workflow breakpoints stops execution and of workflow pipeline on the first task that returns a matching status and throws its `CMDx::Fault`.
57
+
58
+ ```ruby
59
+ CMDx.configure do |config|
60
+ # String or Array[String]
52
61
  config.workflow_breakpoints = ["skipped", "failed"]
53
62
  end
54
63
  ```
@@ -2964,7 +2973,7 @@ Workflow orchestrates sequential execution of multiple tasks in a linear pipelin
2964
2973
 
2965
2974
  ## Declarations
2966
2975
 
2967
- Tasks execute in declaration order (FIFO). The workflow context propagates to each task, allowing access to data from previous executions.
2976
+ Tasks execute sequentially in declaration order (FIFO). The workflow context propagates to each task, allowing access to data from previous executions.
2968
2977
 
2969
2978
  > [!IMPORTANT]
2970
2979
  > Do **NOT** define a `work` method in workflow tasks. The included module automatically provides the execution logic.
data/README.md CHANGED
@@ -122,13 +122,12 @@ end
122
122
 
123
123
  ## Ecosystem
124
124
 
125
+ - [cmdx-i18n](https://github.com/drexed/cmdx-i18n) - 85+ translations
126
+
125
127
  The following gems are currently under development:
126
128
 
127
- - `cmdx-i18n` I18n locales
128
- - `cmdx-rspec` RSpec matchers
129
- - `cmdx-minitest` Minitest matchers
130
- - `cmdx-jobs` Background job integrations
131
- - `cmdx-parallel` Parallel workflow task execution
129
+ - `cmdx-testing` - RSpec and Minitest matchers
130
+ - `cmdx-parallel` - Parallel workflow task execution
132
131
 
133
132
  ## Development
134
133
 
@@ -54,11 +54,20 @@ Globally these settings are initialized with sensible defaults.
54
54
 
55
55
  ### Breakpoints
56
56
 
57
- Breakpoints control when `execute!` raises faults.
57
+ Raise `CMDx::Fault` when a task called with `execute!` returns a matching status.
58
58
 
59
59
  ```ruby
60
60
  CMDx.configure do |config|
61
- config.task_breakpoints = "skipped"
61
+ # String or Array[String]
62
+ config.task_breakpoints = "failed"
63
+ end
64
+ ```
65
+
66
+ Workflow breakpoints stops execution and of workflow pipeline on the first task that returns a matching status and throws its `CMDx::Fault`.
67
+
68
+ ```ruby
69
+ CMDx.configure do |config|
70
+ # String or Array[String]
62
71
  config.workflow_breakpoints = ["skipped", "failed"]
63
72
  end
64
73
  ```
data/docs/workflows.md CHANGED
@@ -15,7 +15,7 @@ Workflow orchestrates sequential execution of multiple tasks in a linear pipelin
15
15
 
16
16
  ## Declarations
17
17
 
18
- Tasks execute in declaration order (FIFO). The workflow context propagates to each task, allowing access to data from previous executions.
18
+ Tasks execute sequentially in declaration order (FIFO). The workflow context propagates to each task, allowing access to data from previous executions.
19
19
 
20
20
  > [!IMPORTANT]
21
21
  > Do **NOT** define a `work` method in workflow tasks. The included module automatically provides the execution logic.
data/lib/cmdx/locale.rb CHANGED
@@ -36,7 +36,7 @@ module CMDx
36
36
  # # => "Custom fallback message"
37
37
  def translate(key, **options)
38
38
  options[:default] ||= EN.dig("en", *key.to_s.split("."))
39
- return I18n.t(key, **options) if defined?(I18n)
39
+ return ::I18n.t(key, **options) if defined?(::I18n)
40
40
 
41
41
  case message = options.delete(:default)
42
42
  when NilClass then "Translation missing: #{key}"
data/lib/cmdx/railtie.rb CHANGED
@@ -23,7 +23,7 @@ module CMDx
23
23
  # # in the CMDx gem's locales directory
24
24
  initializer("cmdx.configure_locales") do |app|
25
25
  Array(app.config.i18n.available_locales).each do |locale|
26
- path = CMDx.gem_path.join("locales/#{locale}.yml")
26
+ path = CMDx.gem_path.join("lib/locales/#{locale}.yml")
27
27
  next unless File.file?(path)
28
28
 
29
29
  I18n.load_path << path
@@ -52,25 +52,27 @@ module CMDx
52
52
  # Length.call("short", not_in: 1..3)
53
53
  # # => nil (validation passes - length 5 is not in excluded range)
54
54
  def call(value, options = {})
55
+ length = value&.length
56
+
55
57
  case options
56
58
  in within:
57
- raise_within_validation_error!(within.begin, within.end, options) unless within.cover?(value.length)
59
+ raise_within_validation_error!(within.begin, within.end, options) unless within&.cover?(length)
58
60
  in not_within:
59
- raise_not_within_validation_error!(not_within.begin, not_within.end, options) if not_within.cover?(value.length)
61
+ raise_not_within_validation_error!(not_within.begin, not_within.end, options) if not_within&.cover?(length)
60
62
  in in: xin
61
- raise_within_validation_error!(xin.begin, xin.end, options) unless xin.cover?(value.length)
63
+ raise_within_validation_error!(xin.begin, xin.end, options) unless xin&.cover?(length)
62
64
  in not_in:
63
- raise_not_within_validation_error!(not_in.begin, not_in.end, options) if not_in.cover?(value.length)
65
+ raise_not_within_validation_error!(not_in.begin, not_in.end, options) if not_in&.cover?(length)
64
66
  in min:, max:
65
- raise_within_validation_error!(min, max, options) unless value.length.between?(min, max)
67
+ raise_within_validation_error!(min, max, options) unless length&.between?(min, max)
66
68
  in min:
67
- raise_min_validation_error!(min, options) unless min <= value.length
69
+ raise_min_validation_error!(min, options) unless !length.nil? && (min <= length)
68
70
  in max:
69
- raise_max_validation_error!(max, options) unless value.length <= max
71
+ raise_max_validation_error!(max, options) unless !length.nil? && (length <= max)
70
72
  in is:
71
- raise_is_validation_error!(is, options) unless value.length == is
73
+ raise_is_validation_error!(is, options) unless !length.nil? && (length == is)
72
74
  in is_not:
73
- raise_is_not_validation_error!(is_not, options) if value.length == is_not
75
+ raise_is_not_validation_error!(is_not, options) if !length.nil? && (length == is_not)
74
76
  else
75
77
  raise ArgumentError, "unknown length validator options given"
76
78
  end
@@ -51,23 +51,23 @@ module CMDx
51
51
  def call(value, options = {})
52
52
  case options
53
53
  in within:
54
- raise_within_validation_error!(within.begin, within.end, options) unless within.cover?(value)
54
+ raise_within_validation_error!(within.begin, within.end, options) unless within&.cover?(value)
55
55
  in not_within:
56
- raise_not_within_validation_error!(not_within.begin, not_within.end, options) if not_within.cover?(value)
56
+ raise_not_within_validation_error!(not_within.begin, not_within.end, options) if not_within&.cover?(value)
57
57
  in in: xin
58
- raise_within_validation_error!(xin.begin, xin.end, options) unless xin.cover?(value)
58
+ raise_within_validation_error!(xin.begin, xin.end, options) unless xin&.cover?(value)
59
59
  in not_in:
60
- raise_not_within_validation_error!(not_in.begin, not_in.end, options) if not_in.cover?(value)
60
+ raise_not_within_validation_error!(not_in.begin, not_in.end, options) if not_in&.cover?(value)
61
61
  in min:, max:
62
- raise_within_validation_error!(min, max, options) unless value.between?(min, max)
62
+ raise_within_validation_error!(min, max, options) unless value&.between?(min, max)
63
63
  in min:
64
- raise_min_validation_error!(min, options) unless min <= value
64
+ raise_min_validation_error!(min, options) unless !value.nil? && (min <= value)
65
65
  in max:
66
- raise_max_validation_error!(max, options) unless value <= max
66
+ raise_max_validation_error!(max, options) unless !value.nil? && (value <= max)
67
67
  in is:
68
- raise_is_validation_error!(is, options) unless value == is
68
+ raise_is_validation_error!(is, options) unless !value.nil? && (value == is)
69
69
  in is_not:
70
- raise_is_not_validation_error!(is_not, options) if value == is_not
70
+ raise_is_not_validation_error!(is_not, options) if !value.nil? && (value == is_not)
71
71
  else
72
72
  raise ArgumentError, "unknown numeric validator options given"
73
73
  end
data/lib/cmdx/version.rb CHANGED
@@ -2,6 +2,6 @@
2
2
 
3
3
  module CMDx
4
4
 
5
- VERSION = "1.5.0"
5
+ VERSION = "1.5.2"
6
6
 
7
7
  end
data/lib/cmdx/workflow.rb CHANGED
@@ -35,10 +35,10 @@ module CMDx
35
35
  # include CMDx::Workflow
36
36
  # task Task1
37
37
  # task Task2
38
- # puts execution_groups.size # => 2
38
+ # puts pipeline.size # => 2
39
39
  # end
40
- def execution_groups
41
- @execution_groups ||= []
40
+ def pipeline
41
+ @pipeline ||= []
42
42
  end
43
43
 
44
44
  # Adds multiple tasks to the workflow with optional configuration.
@@ -56,7 +56,7 @@ module CMDx
56
56
  # tasks ValidateTask, ProcessTask, NotifyTask, breakpoints: [:failure, :halt]
57
57
  # end
58
58
  def tasks(*tasks, **options)
59
- execution_groups << ExecutionGroup.new(
59
+ pipeline << ExecutionGroup.new(
60
60
  tasks.map do |task|
61
61
  next task if task.is_a?(Class) && (task <= Task)
62
62
 
@@ -107,7 +107,7 @@ module CMDx
107
107
  # workflow = DataProcessingWorkflow.new
108
108
  # workflow.work # Stops on first breakpoint encountered
109
109
  def work
110
- self.class.execution_groups.each do |group|
110
+ self.class.pipeline.each do |group|
111
111
  next unless Utils::Condition.evaluate(self, group.options, self)
112
112
 
113
113
  breakpoints = group.options[:breakpoints] || self.class.settings[:workflow_breakpoints]
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.5.0
4
+ version: 1.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juan Gomez
@@ -163,9 +163,7 @@ dependencies:
163
163
  - - ">="
164
164
  - !ruby/object:Gem::Version
165
165
  version: '0'
166
- description: A framework that provides structured command execution, attribute management,
167
- validation, coercion, callbacks, and workflow orchestration for building maintainable
168
- business processes.
166
+ description: CMDx is a framework for building maintainable business processes.
169
167
  email:
170
168
  - drexed@users.noreply.github.com
171
169
  executables: []