cmdx 1.0.1 → 1.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.
Files changed (170) hide show
  1. checksums.yaml +4 -4
  2. data/.cursor/prompts/docs.md +9 -0
  3. data/.cursor/prompts/rspec.md +21 -0
  4. data/.cursor/prompts/yardoc.md +13 -0
  5. data/.rubocop.yml +2 -0
  6. data/CHANGELOG.md +29 -3
  7. data/README.md +2 -1
  8. data/docs/ai_prompts.md +269 -195
  9. data/docs/basics/call.md +126 -60
  10. data/docs/basics/chain.md +190 -160
  11. data/docs/basics/context.md +242 -154
  12. data/docs/basics/setup.md +302 -32
  13. data/docs/callbacks.md +382 -119
  14. data/docs/configuration.md +211 -49
  15. data/docs/deprecation.md +245 -0
  16. data/docs/getting_started.md +161 -39
  17. data/docs/internationalization.md +590 -70
  18. data/docs/interruptions/exceptions.md +135 -118
  19. data/docs/interruptions/faults.md +152 -127
  20. data/docs/interruptions/halt.md +134 -80
  21. data/docs/logging.md +183 -120
  22. data/docs/middlewares.md +165 -392
  23. data/docs/outcomes/result.md +140 -112
  24. data/docs/outcomes/states.md +134 -99
  25. data/docs/outcomes/statuses.md +204 -146
  26. data/docs/parameters/coercions.md +251 -289
  27. data/docs/parameters/defaults.md +224 -169
  28. data/docs/parameters/definitions.md +289 -141
  29. data/docs/parameters/namespacing.md +250 -161
  30. data/docs/parameters/validations.md +247 -159
  31. data/docs/testing.md +196 -203
  32. data/docs/workflows.md +146 -101
  33. data/lib/cmdx/.DS_Store +0 -0
  34. data/lib/cmdx/callback.rb +39 -55
  35. data/lib/cmdx/callback_registry.rb +80 -73
  36. data/lib/cmdx/chain.rb +65 -122
  37. data/lib/cmdx/chain_inspector.rb +23 -116
  38. data/lib/cmdx/chain_serializer.rb +34 -146
  39. data/lib/cmdx/coercion.rb +57 -0
  40. data/lib/cmdx/coercion_registry.rb +113 -0
  41. data/lib/cmdx/coercions/array.rb +18 -36
  42. data/lib/cmdx/coercions/big_decimal.rb +21 -33
  43. data/lib/cmdx/coercions/boolean.rb +21 -40
  44. data/lib/cmdx/coercions/complex.rb +18 -31
  45. data/lib/cmdx/coercions/date.rb +20 -39
  46. data/lib/cmdx/coercions/date_time.rb +22 -39
  47. data/lib/cmdx/coercions/float.rb +19 -32
  48. data/lib/cmdx/coercions/hash.rb +22 -41
  49. data/lib/cmdx/coercions/integer.rb +20 -33
  50. data/lib/cmdx/coercions/rational.rb +20 -32
  51. data/lib/cmdx/coercions/string.rb +23 -31
  52. data/lib/cmdx/coercions/time.rb +24 -40
  53. data/lib/cmdx/coercions/virtual.rb +14 -31
  54. data/lib/cmdx/configuration.rb +101 -162
  55. data/lib/cmdx/context.rb +34 -166
  56. data/lib/cmdx/core_ext/hash.rb +42 -67
  57. data/lib/cmdx/core_ext/module.rb +35 -79
  58. data/lib/cmdx/core_ext/object.rb +63 -98
  59. data/lib/cmdx/correlator.rb +59 -154
  60. data/lib/cmdx/error.rb +37 -202
  61. data/lib/cmdx/errors.rb +153 -216
  62. data/lib/cmdx/fault.rb +68 -150
  63. data/lib/cmdx/faults.rb +26 -137
  64. data/lib/cmdx/immutator.rb +22 -110
  65. data/lib/cmdx/lazy_struct.rb +110 -186
  66. data/lib/cmdx/log_formatters/json.rb +14 -40
  67. data/lib/cmdx/log_formatters/key_value.rb +14 -40
  68. data/lib/cmdx/log_formatters/line.rb +14 -48
  69. data/lib/cmdx/log_formatters/logstash.rb +14 -57
  70. data/lib/cmdx/log_formatters/pretty_json.rb +14 -50
  71. data/lib/cmdx/log_formatters/pretty_key_value.rb +13 -46
  72. data/lib/cmdx/log_formatters/pretty_line.rb +16 -54
  73. data/lib/cmdx/log_formatters/raw.rb +19 -49
  74. data/lib/cmdx/logger.rb +22 -79
  75. data/lib/cmdx/logger_ansi.rb +31 -72
  76. data/lib/cmdx/logger_serializer.rb +74 -103
  77. data/lib/cmdx/middleware.rb +56 -60
  78. data/lib/cmdx/middleware_registry.rb +82 -77
  79. data/lib/cmdx/middlewares/correlate.rb +41 -226
  80. data/lib/cmdx/middlewares/timeout.rb +46 -185
  81. data/lib/cmdx/parameter.rb +167 -183
  82. data/lib/cmdx/parameter_evaluator.rb +231 -0
  83. data/lib/cmdx/parameter_inspector.rb +37 -55
  84. data/lib/cmdx/parameter_registry.rb +65 -84
  85. data/lib/cmdx/parameter_serializer.rb +32 -76
  86. data/lib/cmdx/railtie.rb +24 -107
  87. data/lib/cmdx/result.rb +254 -259
  88. data/lib/cmdx/result_ansi.rb +28 -80
  89. data/lib/cmdx/result_inspector.rb +34 -70
  90. data/lib/cmdx/result_logger.rb +23 -77
  91. data/lib/cmdx/result_serializer.rb +59 -125
  92. data/lib/cmdx/rspec/matchers.rb +28 -0
  93. data/lib/cmdx/rspec/result_matchers/be_executed.rb +42 -0
  94. data/lib/cmdx/rspec/result_matchers/be_failed_task.rb +94 -0
  95. data/lib/cmdx/rspec/result_matchers/be_skipped_task.rb +94 -0
  96. data/lib/cmdx/rspec/result_matchers/be_state_matchers.rb +59 -0
  97. data/lib/cmdx/rspec/result_matchers/be_status_matchers.rb +57 -0
  98. data/lib/cmdx/rspec/result_matchers/be_successful_task.rb +87 -0
  99. data/lib/cmdx/rspec/result_matchers/have_bad_outcome.rb +51 -0
  100. data/lib/cmdx/rspec/result_matchers/have_caused_failure.rb +58 -0
  101. data/lib/cmdx/rspec/result_matchers/have_chain_index.rb +59 -0
  102. data/lib/cmdx/rspec/result_matchers/have_context.rb +86 -0
  103. data/lib/cmdx/rspec/result_matchers/have_empty_metadata.rb +54 -0
  104. data/lib/cmdx/rspec/result_matchers/have_good_outcome.rb +52 -0
  105. data/lib/cmdx/rspec/result_matchers/have_metadata.rb +114 -0
  106. data/lib/cmdx/rspec/result_matchers/have_preserved_context.rb +66 -0
  107. data/lib/cmdx/rspec/result_matchers/have_received_thrown_failure.rb +64 -0
  108. data/lib/cmdx/rspec/result_matchers/have_runtime.rb +78 -0
  109. data/lib/cmdx/rspec/result_matchers/have_thrown_failure.rb +76 -0
  110. data/lib/cmdx/rspec/task_matchers/be_well_formed_task.rb +62 -0
  111. data/lib/cmdx/rspec/task_matchers/have_callback.rb +85 -0
  112. data/lib/cmdx/rspec/task_matchers/have_cmd_setting.rb +68 -0
  113. data/lib/cmdx/rspec/task_matchers/have_executed_callbacks.rb +92 -0
  114. data/lib/cmdx/rspec/task_matchers/have_middleware.rb +46 -0
  115. data/lib/cmdx/rspec/task_matchers/have_parameter.rb +181 -0
  116. data/lib/cmdx/task.rb +336 -427
  117. data/lib/cmdx/task_deprecator.rb +52 -0
  118. data/lib/cmdx/task_processor.rb +246 -0
  119. data/lib/cmdx/task_serializer.rb +34 -69
  120. data/lib/cmdx/utils/ansi_color.rb +13 -89
  121. data/lib/cmdx/utils/log_timestamp.rb +13 -42
  122. data/lib/cmdx/utils/monotonic_runtime.rb +11 -63
  123. data/lib/cmdx/utils/name_affix.rb +21 -71
  124. data/lib/cmdx/validator.rb +57 -0
  125. data/lib/cmdx/validator_registry.rb +108 -0
  126. data/lib/cmdx/validators/exclusion.rb +55 -94
  127. data/lib/cmdx/validators/format.rb +31 -85
  128. data/lib/cmdx/validators/inclusion.rb +65 -110
  129. data/lib/cmdx/validators/length.rb +117 -133
  130. data/lib/cmdx/validators/numeric.rb +123 -130
  131. data/lib/cmdx/validators/presence.rb +38 -79
  132. data/lib/cmdx/version.rb +1 -7
  133. data/lib/cmdx/workflow.rb +58 -330
  134. data/lib/cmdx.rb +1 -1
  135. data/lib/generators/cmdx/install_generator.rb +14 -31
  136. data/lib/generators/cmdx/task_generator.rb +39 -55
  137. data/lib/generators/cmdx/templates/install.rb +24 -6
  138. data/lib/generators/cmdx/workflow_generator.rb +41 -66
  139. data/lib/locales/ar.yml +0 -1
  140. data/lib/locales/cs.yml +0 -1
  141. data/lib/locales/da.yml +0 -1
  142. data/lib/locales/de.yml +0 -1
  143. data/lib/locales/el.yml +0 -1
  144. data/lib/locales/en.yml +0 -1
  145. data/lib/locales/es.yml +0 -1
  146. data/lib/locales/fi.yml +0 -1
  147. data/lib/locales/fr.yml +0 -1
  148. data/lib/locales/he.yml +0 -1
  149. data/lib/locales/hi.yml +0 -1
  150. data/lib/locales/it.yml +0 -1
  151. data/lib/locales/ja.yml +0 -1
  152. data/lib/locales/ko.yml +0 -1
  153. data/lib/locales/nl.yml +0 -1
  154. data/lib/locales/no.yml +0 -1
  155. data/lib/locales/pl.yml +0 -1
  156. data/lib/locales/pt.yml +0 -1
  157. data/lib/locales/ru.yml +0 -1
  158. data/lib/locales/sv.yml +0 -1
  159. data/lib/locales/th.yml +0 -1
  160. data/lib/locales/tr.yml +0 -1
  161. data/lib/locales/vi.yml +0 -1
  162. data/lib/locales/zh.yml +0 -1
  163. metadata +36 -8
  164. data/lib/cmdx/parameter_validator.rb +0 -81
  165. data/lib/cmdx/parameter_value.rb +0 -244
  166. data/lib/cmdx/parameters_inspector.rb +0 -72
  167. data/lib/cmdx/parameters_serializer.rb +0 -115
  168. data/lib/cmdx/rspec/result_matchers.rb +0 -917
  169. data/lib/cmdx/rspec/task_matchers.rb +0 -570
  170. data/lib/cmdx/validators/custom.rb +0 -102
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c2d77bd913e65961bafa2851e2148df1daed63bd7047f512f53f10b9ec07b700
4
- data.tar.gz: 7d86f82f6334bb4538fdbbaeafa60185de6cd55535e192832ccb8c40164996dd
3
+ metadata.gz: 2517b9b2e36f957800d10bf952bd8062fbcd4c66ff760574c741c96b5d76d925
4
+ data.tar.gz: f52d86024e590060604c17da1ff31ed520d9f5d561367d6ef59b6df93ed01b45
5
5
  SHA512:
6
- metadata.gz: 4802141926139cf972a9869884fe59cddfca218a6ac8a54791e4a575ecef9f9b59039a71147097e5758e6171ef600c2d005110fc84bc27e5dd26f4930541b32d
7
- data.tar.gz: b9eb23fd437ffc81ea9441273bf5602220167368af96d2190e9f2623d33eee7cf48af8c9fbfa947f802db0d378eb93f9661de04d8477759f312bf7bb0c9c1054
6
+ metadata.gz: b260acf4cf76fa11cb9af6fd498536c8260b813880fb46dca0569162eda32d08f67c9a3ccd06611a84fc75067b7b49c8365beebeafc766b6098961cf2fa46830
7
+ data.tar.gz: 7fe5dd38adfdee7db0b54f2748f19a74bbe34da632288275fd012a4ea15216ad8bc35a8e189e9274463797511d59f260063dab2903d9052968fbb69653bb93ef
@@ -0,0 +1,9 @@
1
+ Update the file in context using the following guidelines:
2
+
3
+ - Follow best practices and implementation
4
+ - Use a consistent professional voice
5
+ - Examples should be concise, non-repetitive, and realistic
6
+ - Update any pre-existing documentation to match stated rules
7
+ - Examples should not cross boundaries or focus
8
+ - Docs must cover both typical use cases, including invalid inputs and error conditions
9
+ - Use GitHub flavored markdown, including alerts to emphasize critical information (https://github.com/orgs/community/discussions/16925)
@@ -0,0 +1,21 @@
1
+ Add tests for the file in context using the following guidelines:
2
+
3
+ - Expectations should be concise, non-repetitive, and realistic (how it would be used in the real world)
4
+ - Follow best practices and implementation
5
+ - Update any pre-existing specs to match stated rules
6
+ - New tests should be consistent with current `spec/cmdx` specs
7
+ - Use custom matchers available within `lib/cmdx/rspec`
8
+ - Use task helpers available within `spec/support/helpers`
9
+ - Use stubs to return predefined values for specific methods. Isolate the unit being tested, but avoid over-mocking; test real behavior when possible (mocks should be used only when necessary)
10
+ - Ensure each test is independent; avoid shared state between tests
11
+ - Use let and let! to define test data, ensuring minimal and necessary setup
12
+ - Context block descriptions should start with the following words: `when`, `with`, `without`
13
+ - Organize tests logically using describe for classes/modules and context for different scenarios
14
+ - Use subject to define the object under test when appropriate to avoid repetition
15
+ - Ensure test file paths mirror the structure of the files being tested, but within the spec directory (e.g., lib/cmdx/task.rb → spec/cmdx/task_spec.rb)
16
+ - Use clear and descriptive names for describe, context, and it blocks
17
+ - Prefer the expect syntax for assertions to improve readability
18
+ - Keep test code concise; avoid unnecessary complexity or duplication
19
+ - Tests must cover both typical cases and edge cases, including invalid inputs and error conditions
20
+ - Consider all possible scenarios for each method or behavior and ensure they are tested
21
+ - Verify all specs are passing
@@ -0,0 +1,13 @@
1
+ Add yardoc to the file in context using the following guidelines:
2
+
3
+ - Follow best practices and implementation
4
+ - New documentation should be consistent with current `lib/cmdx` documentation
5
+ - Examples should be concise, non-repetitive, and realistic
6
+ - Avoid unnecessary complexity or duplication
7
+ - Consider all possible scenarios for each method or behavior and ensure they are tested.
8
+ - Update any pre-existing documentation to match stated rules
9
+ - Do NOT include `CMDx` module level docs
10
+ - Module level docs description should NOT include `@example`
11
+ - Method level docs should include `@example`, `param`, `@options`, `@return`, and any `@raise`
12
+ - Hash `@params` should expand with possible `@option`
13
+ - Module and method level docs should NOT include `@since`
data/.rubocop.yml CHANGED
@@ -62,6 +62,8 @@ RSpec/SpecFilePathFormat:
62
62
  CMDx: cmdx
63
63
  RSpec/StubbedMock:
64
64
  Enabled: false
65
+ RSpec/SubjectStub:
66
+ Enabled: false
65
67
  RSpec/VerifiedDoubles:
66
68
  Enabled: false
67
69
  RSpec/VerifiedDoubleReference:
data/CHANGELOG.md CHANGED
@@ -7,12 +7,38 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [TODO]
9
9
 
10
- - Add table and pretty_table log formatters
11
- - Add method and proc style validations
12
- - Refactor parameter modules and classes for more robust usages
10
+ - Rebuild parameters to use a less magical approach
11
+ - Validators to add errors directly instead of raising errors
12
+ - Coercions to add errors directly instead of raising errors
13
+ - Update procs to call with object as first item
13
14
 
14
15
  ## [Unreleased]
15
16
 
17
+ ## [1.1.1] - 2025-07-20
18
+
19
+ ### Changed
20
+ - Updated all docs and specs
21
+ - Update deprecation key words
22
+
23
+ ## [1.1.0] - 2025-07-17
24
+
25
+ ### Added
26
+ - Added `CoercionRegistry` class for managing parameter coercions with support for custom type registration
27
+ - Added `ValidatorRegistry` class for managing parameter validators with support for custom validator registration
28
+ - Added `CallbackRegistry` class to take uninstantiated callback classes
29
+ - Added `Validator` and `Coercion` classes to build their respective handlers
30
+ - Added deprecation setting
31
+
32
+ ### Changed
33
+ - Moved `Task::CALLBACKS` constant to `CallbackRegistry::TYPES`
34
+ - Updated `ParameterRegistry` class to not inherit from `Hash`
35
+ - Updated `MiddlewareRegistry` class to not inherit from `Hash`
36
+ - Updated `CallbackRegistry` class to not inherit from `Hash`
37
+
38
+ ### Removed
39
+ - Removed task `register` class method
40
+ - Removed `Custom` validator since users can create and register a custom one
41
+
16
42
  ## [1.0.1] - 2025-07-07
17
43
 
18
44
  ### Added
data/README.md CHANGED
@@ -31,7 +31,7 @@ Or install it yourself as:
31
31
  ```ruby
32
32
  # Setup task
33
33
  class SendWelcomeEmailTask < CMDx::Task
34
- use CMDx::Middlewares::Timeout, seconds: 5
34
+ use :middleware, CMDx::Middlewares::Timeout, seconds: 5
35
35
 
36
36
  on_success :track_email_delivery!
37
37
 
@@ -102,6 +102,7 @@ end
102
102
  - [Logging](docs/logging.md)
103
103
  - [Internationalization (i18n)](docs/internationalization.md)
104
104
  - [Testing](docs/testing.md)
105
+ - [Deprecation](docs/deprecation.md)
105
106
  - [AI Prompts](docs/ai_prompts.md)
106
107
  - [Tips & Tricks](docs/tips_and_tricks.md)
107
108