cmdx 1.12.0 → 1.14.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 +88 -71
- data/LICENSE.txt +3 -20
- data/README.md +8 -7
- data/lib/cmdx/attribute.rb +21 -5
- data/lib/cmdx/chain.rb +18 -4
- data/lib/cmdx/context.rb +18 -0
- data/lib/cmdx/executor.rb +35 -30
- data/lib/cmdx/result.rb +45 -2
- data/lib/cmdx/task.rb +22 -1
- data/lib/cmdx/version.rb +1 -1
- data/mkdocs.yml +67 -37
- metadata +3 -57
- data/.cursor/prompts/docs.md +0 -12
- data/.cursor/prompts/llms.md +0 -8
- data/.cursor/prompts/rspec.md +0 -24
- data/.cursor/prompts/yardoc.md +0 -15
- data/.cursor/rules/cursor-instructions.mdc +0 -68
- data/.irbrc +0 -18
- data/.rspec +0 -4
- data/.rubocop.yml +0 -95
- data/.ruby-version +0 -1
- data/.yard-lint.yml +0 -174
- data/.yardopts +0 -7
- data/docs/.DS_Store +0 -0
- data/docs/assets/favicon.ico +0 -0
- data/docs/assets/favicon.svg +0 -1
- data/docs/attributes/coercions.md +0 -155
- data/docs/attributes/defaults.md +0 -77
- data/docs/attributes/definitions.md +0 -283
- data/docs/attributes/naming.md +0 -68
- data/docs/attributes/transformations.md +0 -63
- data/docs/attributes/validations.md +0 -336
- data/docs/basics/chain.md +0 -108
- data/docs/basics/context.md +0 -121
- data/docs/basics/execution.md +0 -96
- data/docs/basics/setup.md +0 -84
- data/docs/callbacks.md +0 -157
- data/docs/configuration.md +0 -314
- data/docs/deprecation.md +0 -145
- data/docs/getting_started.md +0 -126
- data/docs/index.md +0 -134
- data/docs/internationalization.md +0 -126
- data/docs/interruptions/exceptions.md +0 -52
- data/docs/interruptions/faults.md +0 -169
- data/docs/interruptions/halt.md +0 -216
- data/docs/logging.md +0 -94
- data/docs/middlewares.md +0 -191
- data/docs/outcomes/result.md +0 -194
- data/docs/outcomes/states.md +0 -66
- data/docs/outcomes/statuses.md +0 -65
- data/docs/retries.md +0 -121
- data/docs/stylesheets/extra.css +0 -42
- data/docs/tips_and_tricks.md +0 -157
- data/docs/workflows.md +0 -226
- data/examples/active_record_database_transaction.md +0 -27
- data/examples/active_record_query_tagging.md +0 -46
- data/examples/flipper_feature_flags.md +0 -50
- data/examples/paper_trail_whatdunnit.md +0 -39
- data/examples/redis_idempotency.md +0 -71
- data/examples/sentry_error_tracking.md +0 -46
- data/examples/sidekiq_async_execution.md +0 -29
- data/examples/stoplight_circuit_breaker.md +0 -36
- data/src/cmdx-dark-logo.png +0 -0
- data/src/cmdx-favicon.svg +0 -1
- data/src/cmdx-light-logo.png +0 -0
- data/src/cmdx-logo.svg +0 -1
data/lib/cmdx/result.rb
CHANGED
|
@@ -70,7 +70,7 @@ module CMDx
|
|
|
70
70
|
# @return [Hash{Symbol => Object}] Metadata hash
|
|
71
71
|
#
|
|
72
72
|
# @example
|
|
73
|
-
# result.metadata # => { duration: 1.5,
|
|
73
|
+
# result.metadata # => { duration: 1.5, code: 200, message: "Success" }
|
|
74
74
|
#
|
|
75
75
|
# @rbs @metadata: Hash[Symbol, untyped]
|
|
76
76
|
attr_reader :metadata
|
|
@@ -95,7 +95,27 @@ module CMDx
|
|
|
95
95
|
# @rbs @cause: (Exception | nil)
|
|
96
96
|
attr_reader :cause
|
|
97
97
|
|
|
98
|
-
|
|
98
|
+
# Returns the number of retries attempted.
|
|
99
|
+
#
|
|
100
|
+
# @return [Integer] The number of retries attempted
|
|
101
|
+
#
|
|
102
|
+
# @example
|
|
103
|
+
# result.retries # => 2
|
|
104
|
+
#
|
|
105
|
+
# @rbs @retries: Integer
|
|
106
|
+
attr_accessor :retries
|
|
107
|
+
|
|
108
|
+
# Returns whether the result has been rolled back.
|
|
109
|
+
#
|
|
110
|
+
# @return [Boolean] Whether the result has been rolled back
|
|
111
|
+
#
|
|
112
|
+
# @example
|
|
113
|
+
# result.rolled_back? # => true
|
|
114
|
+
#
|
|
115
|
+
# @rbs @rolled_back: bool
|
|
116
|
+
attr_accessor :rolled_back
|
|
117
|
+
|
|
118
|
+
def_delegators :task, :context, :chain, :errors, :dry_run?
|
|
99
119
|
alias ctx context
|
|
100
120
|
|
|
101
121
|
# @param task [CMDx::Task] The task instance this result represents
|
|
@@ -118,6 +138,8 @@ module CMDx
|
|
|
118
138
|
@metadata = {}
|
|
119
139
|
@reason = nil
|
|
120
140
|
@cause = nil
|
|
141
|
+
@retries = 0
|
|
142
|
+
@rolled_back = false
|
|
121
143
|
end
|
|
122
144
|
|
|
123
145
|
STATES.each do |s|
|
|
@@ -419,6 +441,26 @@ module CMDx
|
|
|
419
441
|
failed? && !caused_failure?
|
|
420
442
|
end
|
|
421
443
|
|
|
444
|
+
# @return [Boolean] Whether the result has been retried
|
|
445
|
+
#
|
|
446
|
+
# @example
|
|
447
|
+
# result.retried? # => true
|
|
448
|
+
#
|
|
449
|
+
# @rbs () -> bool
|
|
450
|
+
def retried?
|
|
451
|
+
retries.positive?
|
|
452
|
+
end
|
|
453
|
+
|
|
454
|
+
# @return [Boolean] Whether the result has been rolled back
|
|
455
|
+
#
|
|
456
|
+
# @example
|
|
457
|
+
# result.rolled_back? # => true
|
|
458
|
+
#
|
|
459
|
+
# @rbs () -> bool
|
|
460
|
+
def rolled_back?
|
|
461
|
+
!!@rolled_back
|
|
462
|
+
end
|
|
463
|
+
|
|
422
464
|
# @return [Integer] Index of this result in the chain
|
|
423
465
|
#
|
|
424
466
|
# @example
|
|
@@ -457,6 +499,7 @@ module CMDx
|
|
|
457
499
|
if interrupted?
|
|
458
500
|
hash[:reason] = reason
|
|
459
501
|
hash[:cause] = cause
|
|
502
|
+
hash[:rolled_back] = rolled_back?
|
|
460
503
|
end
|
|
461
504
|
|
|
462
505
|
if failed?
|
data/lib/cmdx/task.rb
CHANGED
|
@@ -71,6 +71,7 @@ module CMDx
|
|
|
71
71
|
attr_reader :chain
|
|
72
72
|
|
|
73
73
|
def_delegators :result, :skip!, :fail!, :throw!
|
|
74
|
+
def_delegators :chain, :dry_run?
|
|
74
75
|
|
|
75
76
|
# @param context [Hash, Context] The initial context for the task
|
|
76
77
|
#
|
|
@@ -94,7 +95,7 @@ module CMDx
|
|
|
94
95
|
@id = Identifier.generate
|
|
95
96
|
@context = Context.build(context)
|
|
96
97
|
@result = Result.new(self)
|
|
97
|
-
@chain = Chain.build(@result)
|
|
98
|
+
@chain = Chain.build(@result, dry_run: @context.delete(:dry_run))
|
|
98
99
|
end
|
|
99
100
|
|
|
100
101
|
class << self
|
|
@@ -216,6 +217,25 @@ module CMDx
|
|
|
216
217
|
end
|
|
217
218
|
alias remove_attribute remove_attributes
|
|
218
219
|
|
|
220
|
+
# @return [Hash] Hash of attribute names to their configurations
|
|
221
|
+
#
|
|
222
|
+
# @example
|
|
223
|
+
# MyTask.attributes_schema #=> {
|
|
224
|
+
# user_id: { name: :user_id, method_name: :user_id, required: true, types: [:integer], options: {}, children: [] },
|
|
225
|
+
# email: { name: :email, method_name: :email, required: false, types: [:string], options: { default: nil }, children: [] },
|
|
226
|
+
# profile: { name: :profile, method_name: :profile, required: false, types: [:hash], options: {}, children: [
|
|
227
|
+
# { name: :bio, method_name: :bio, required: false, types: [:string], options: {}, children: [] },
|
|
228
|
+
# { name: :name, method_name: :name, required: true, types: [:string], options: {}, children: [] }
|
|
229
|
+
# ] }
|
|
230
|
+
# }
|
|
231
|
+
#
|
|
232
|
+
# @rbs () -> Hash[Symbol, Hash[Symbol, untyped]]
|
|
233
|
+
def attributes_schema
|
|
234
|
+
Array(settings[:attributes]).each_with_object({}) do |attr, schema|
|
|
235
|
+
schema[attr.method_name] = attr.to_h
|
|
236
|
+
end
|
|
237
|
+
end
|
|
238
|
+
|
|
219
239
|
CallbackRegistry::TYPES.each do |callback|
|
|
220
240
|
# @param callables [Array] Callable objects to register as callbacks
|
|
221
241
|
# @param options [Hash] Options for the callback registration
|
|
@@ -341,6 +361,7 @@ module CMDx
|
|
|
341
361
|
type: self.class.include?(Workflow) ? "Workflow" : "Task",
|
|
342
362
|
tags: self.class.settings[:tags],
|
|
343
363
|
class: self.class.name,
|
|
364
|
+
dry_run: dry_run?,
|
|
344
365
|
id:
|
|
345
366
|
}
|
|
346
367
|
end
|
data/lib/cmdx/version.rb
CHANGED
data/mkdocs.yml
CHANGED
|
@@ -54,6 +54,8 @@ theme:
|
|
|
54
54
|
- navigation.expand
|
|
55
55
|
- navigation.path
|
|
56
56
|
- navigation.sections
|
|
57
|
+
- navigation.tabs
|
|
58
|
+
- navigation.tabs.sticky
|
|
57
59
|
- navigation.top
|
|
58
60
|
- navigation.tracking
|
|
59
61
|
- search.highlight
|
|
@@ -65,7 +67,11 @@ markdown_extensions:
|
|
|
65
67
|
- attr_list
|
|
66
68
|
- md_in_html
|
|
67
69
|
- pymdownx.details
|
|
68
|
-
- pymdownx.superfences
|
|
70
|
+
- pymdownx.superfences:
|
|
71
|
+
custom_fences:
|
|
72
|
+
- name: mermaid
|
|
73
|
+
class: mermaid
|
|
74
|
+
format: !!python/name:pymdownx.superfences.fence_code_format
|
|
69
75
|
- pymdownx.highlight:
|
|
70
76
|
anchor_linenums: true
|
|
71
77
|
line_spans: __span
|
|
@@ -77,9 +83,25 @@ markdown_extensions:
|
|
|
77
83
|
- tables
|
|
78
84
|
- toc:
|
|
79
85
|
permalink: true
|
|
86
|
+
title: On this page
|
|
80
87
|
|
|
81
88
|
plugins:
|
|
82
89
|
- search
|
|
90
|
+
- rss:
|
|
91
|
+
match_path: blog/posts/.*
|
|
92
|
+
date_from_meta:
|
|
93
|
+
as_creation: date
|
|
94
|
+
categories:
|
|
95
|
+
- categories
|
|
96
|
+
- blog:
|
|
97
|
+
blog_dir: blog
|
|
98
|
+
blog_toc: true
|
|
99
|
+
post_date_format: long
|
|
100
|
+
post_url_format: "{slug}"
|
|
101
|
+
archive_date_format: MMMM yyyy
|
|
102
|
+
categories_allowed:
|
|
103
|
+
- Tutorials
|
|
104
|
+
- Updates
|
|
83
105
|
- llmstxt:
|
|
84
106
|
markdown_description: >-
|
|
85
107
|
CMDx is a Ruby framework for building maintainable, observable business logic through composable command/service objects.
|
|
@@ -120,51 +142,59 @@ plugins:
|
|
|
120
142
|
- workflows.md: Composing multiple tasks into sequential pipelines with conditional execution
|
|
121
143
|
More:
|
|
122
144
|
- tips_and_tricks.md: Best practices, patterns, and techniques for maintainable CMDx applications
|
|
145
|
+
Ecosystem:
|
|
146
|
+
- cmdx-rspec: RSpec test matchers (https://github.com/drexed/cmdx-rspec)
|
|
123
147
|
|
|
124
148
|
nav:
|
|
125
149
|
- Home: index.md
|
|
126
|
-
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
-
|
|
158
|
-
|
|
159
|
-
-
|
|
160
|
-
|
|
161
|
-
|
|
150
|
+
- Documentation:
|
|
151
|
+
- Getting Started: getting_started.md
|
|
152
|
+
- Configuration: configuration.md
|
|
153
|
+
- Basics:
|
|
154
|
+
- Setup: basics/setup.md
|
|
155
|
+
- Execution: basics/execution.md
|
|
156
|
+
- Context: basics/context.md
|
|
157
|
+
- Chain: basics/chain.md
|
|
158
|
+
- Interruptions:
|
|
159
|
+
- Halt: interruptions/halt.md
|
|
160
|
+
- Faults: interruptions/faults.md
|
|
161
|
+
- Exceptions: interruptions/exceptions.md
|
|
162
|
+
- Outcomes:
|
|
163
|
+
- Result: outcomes/result.md
|
|
164
|
+
- States: outcomes/states.md
|
|
165
|
+
- Statuses: outcomes/statuses.md
|
|
166
|
+
- Attributes:
|
|
167
|
+
- Definitions: attributes/definitions.md
|
|
168
|
+
- Naming: attributes/naming.md
|
|
169
|
+
- Coercions: attributes/coercions.md
|
|
170
|
+
- Validations: attributes/validations.md
|
|
171
|
+
- Defaults: attributes/defaults.md
|
|
172
|
+
- Transformations: attributes/transformations.md
|
|
173
|
+
- Features:
|
|
174
|
+
- Callbacks: callbacks.md
|
|
175
|
+
- Middlewares: middlewares.md
|
|
176
|
+
- Logging: logging.md
|
|
177
|
+
- Internationalization: internationalization.md
|
|
178
|
+
- Retries: retries.md
|
|
179
|
+
- Deprecation: deprecation.md
|
|
180
|
+
- Workflows: workflows.md
|
|
181
|
+
- More:
|
|
182
|
+
- Tips and Tricks: tips_and_tricks.md
|
|
183
|
+
- References:
|
|
184
|
+
- API Documentation: https://drexed.github.io/cmdx/api/index.html
|
|
185
|
+
- llms.txt: https://drexed.github.io/cmdx/llms.txt
|
|
186
|
+
- llms-full.txt: https://drexed.github.io/cmdx/llms-full.txt
|
|
187
|
+
- Ecosystem:
|
|
188
|
+
- cmdx-rspec: https://github.com/drexed/cmdx-rspec
|
|
189
|
+
- Blog: blog/index.md
|
|
162
190
|
|
|
163
191
|
extra:
|
|
164
192
|
generator: false
|
|
165
193
|
social:
|
|
166
194
|
- icon: fontawesome/brands/github
|
|
167
195
|
link: https://github.com/drexed/cmdx
|
|
196
|
+
- icon: fontawesome/solid/rss
|
|
197
|
+
link: https://drexed.github.io/cmdx/feed_rss_created.xml
|
|
168
198
|
|
|
169
199
|
extra_css:
|
|
170
200
|
- stylesheets/extra.css
|
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.14.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Juan Gomez
|
|
@@ -227,61 +227,11 @@ extensions: []
|
|
|
227
227
|
extra_rdoc_files: []
|
|
228
228
|
files:
|
|
229
229
|
- ".DS_Store"
|
|
230
|
-
- ".cursor/prompts/docs.md"
|
|
231
|
-
- ".cursor/prompts/llms.md"
|
|
232
|
-
- ".cursor/prompts/rspec.md"
|
|
233
|
-
- ".cursor/prompts/yardoc.md"
|
|
234
|
-
- ".cursor/rules/cursor-instructions.mdc"
|
|
235
|
-
- ".irbrc"
|
|
236
|
-
- ".rspec"
|
|
237
|
-
- ".rubocop.yml"
|
|
238
|
-
- ".ruby-version"
|
|
239
|
-
- ".yard-lint.yml"
|
|
240
|
-
- ".yardopts"
|
|
241
230
|
- CHANGELOG.md
|
|
242
231
|
- CODE_OF_CONDUCT.md
|
|
243
232
|
- LICENSE.txt
|
|
244
233
|
- README.md
|
|
245
234
|
- Rakefile
|
|
246
|
-
- docs/.DS_Store
|
|
247
|
-
- docs/assets/favicon.ico
|
|
248
|
-
- docs/assets/favicon.svg
|
|
249
|
-
- docs/attributes/coercions.md
|
|
250
|
-
- docs/attributes/defaults.md
|
|
251
|
-
- docs/attributes/definitions.md
|
|
252
|
-
- docs/attributes/naming.md
|
|
253
|
-
- docs/attributes/transformations.md
|
|
254
|
-
- docs/attributes/validations.md
|
|
255
|
-
- docs/basics/chain.md
|
|
256
|
-
- docs/basics/context.md
|
|
257
|
-
- docs/basics/execution.md
|
|
258
|
-
- docs/basics/setup.md
|
|
259
|
-
- docs/callbacks.md
|
|
260
|
-
- docs/configuration.md
|
|
261
|
-
- docs/deprecation.md
|
|
262
|
-
- docs/getting_started.md
|
|
263
|
-
- docs/index.md
|
|
264
|
-
- docs/internationalization.md
|
|
265
|
-
- docs/interruptions/exceptions.md
|
|
266
|
-
- docs/interruptions/faults.md
|
|
267
|
-
- docs/interruptions/halt.md
|
|
268
|
-
- docs/logging.md
|
|
269
|
-
- docs/middlewares.md
|
|
270
|
-
- docs/outcomes/result.md
|
|
271
|
-
- docs/outcomes/states.md
|
|
272
|
-
- docs/outcomes/statuses.md
|
|
273
|
-
- docs/retries.md
|
|
274
|
-
- docs/stylesheets/extra.css
|
|
275
|
-
- docs/tips_and_tricks.md
|
|
276
|
-
- docs/workflows.md
|
|
277
|
-
- examples/active_record_database_transaction.md
|
|
278
|
-
- examples/active_record_query_tagging.md
|
|
279
|
-
- examples/flipper_feature_flags.md
|
|
280
|
-
- examples/paper_trail_whatdunnit.md
|
|
281
|
-
- examples/redis_idempotency.md
|
|
282
|
-
- examples/sentry_error_tracking.md
|
|
283
|
-
- examples/sidekiq_async_execution.md
|
|
284
|
-
- examples/stoplight_circuit_breaker.md
|
|
285
235
|
- lib/cmdx.rb
|
|
286
236
|
- lib/cmdx/.DS_Store
|
|
287
237
|
- lib/cmdx/attribute.rb
|
|
@@ -431,13 +381,9 @@ files:
|
|
|
431
381
|
- lib/locales/zh-TW.yml
|
|
432
382
|
- lib/locales/zh-YUE.yml
|
|
433
383
|
- mkdocs.yml
|
|
434
|
-
- src/cmdx-dark-logo.png
|
|
435
|
-
- src/cmdx-favicon.svg
|
|
436
|
-
- src/cmdx-light-logo.png
|
|
437
|
-
- src/cmdx-logo.svg
|
|
438
384
|
homepage: https://github.com/drexed/cmdx
|
|
439
385
|
licenses:
|
|
440
|
-
-
|
|
386
|
+
- LGPL-3.0
|
|
441
387
|
metadata:
|
|
442
388
|
homepage_uri: https://github.com/drexed/cmdx
|
|
443
389
|
source_code_uri: https://github.com/drexed/cmdx
|
|
@@ -459,7 +405,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
459
405
|
- !ruby/object:Gem::Version
|
|
460
406
|
version: '0'
|
|
461
407
|
requirements: []
|
|
462
|
-
rubygems_version:
|
|
408
|
+
rubygems_version: 4.0.3
|
|
463
409
|
specification_version: 4
|
|
464
410
|
summary: CMDx is a framework for building maintainable business processes.
|
|
465
411
|
test_files: []
|
data/.cursor/prompts/docs.md
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
You are a senior Ruby developer with expert knowledge of CMDx and writing documentation.
|
|
2
|
-
|
|
3
|
-
Update the active tab using the following guidelines:
|
|
4
|
-
|
|
5
|
-
- Follow best practices and implementation
|
|
6
|
-
- Use a consistent warm, friendly and professional voice
|
|
7
|
-
- Examples should be concise, non-repetitive, and realistic
|
|
8
|
-
- Update any pre-existing documentation to match stated rules
|
|
9
|
-
- Examples should not cross boundaries or focus
|
|
10
|
-
- Docs must cover both typical use cases, including invalid and error conditions
|
|
11
|
-
- Use mkdocs Admonitions to emphasize critical information (https://squidfunk.github.io/mkdocs-material/reference/admonitions/)
|
|
12
|
-
- Optimize for LLM's including coding and AI agents
|
data/.cursor/prompts/llms.md
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
Process the following instructions in the order given:
|
|
2
|
-
|
|
3
|
-
1. Create an `LLM.md` file
|
|
4
|
-
2. Append all files within `docs/**/*.md` into @LLM.md
|
|
5
|
-
2a. Use order outlined under the nav key in @mkdocs.yml
|
|
6
|
-
2b. Process one file at a time faster performance and improved accuracy
|
|
7
|
-
2c. Exclude @index.md and @LLM.md files
|
|
8
|
-
2d. All URLs should be absolute
|
data/.cursor/prompts/rspec.md
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
You are a senior Ruby developer with expert knowledge of RSpec.
|
|
2
|
-
|
|
3
|
-
Add tests for the active tab using the following guidelines:
|
|
4
|
-
|
|
5
|
-
- Expectations should be concise, non-repetitive, and realistic (how it would be used in the real world)
|
|
6
|
-
- Follow best practices and implementation
|
|
7
|
-
- Update any pre-existing specs to match stated rules
|
|
8
|
-
- New tests should be consistent with current `spec/cmdx` specs
|
|
9
|
-
- Use custom matchers available within `lib/cmdx/rspec`
|
|
10
|
-
- Use task helpers available within `spec/support/helpers`
|
|
11
|
-
- 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)
|
|
12
|
-
- Ensure each test is independent; avoid shared state between tests
|
|
13
|
-
- Use let and let! to define test data, ensuring minimal and necessary setup
|
|
14
|
-
- Context block descriptions should start with the following words: `when`, `with`, `without`
|
|
15
|
-
- Organize tests logically using describe for classes/modules and context for different scenarios
|
|
16
|
-
- Use subject to define the object under test when appropriate to avoid repetition
|
|
17
|
-
- 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)
|
|
18
|
-
- Use clear and descriptive names for describe, context, and it blocks
|
|
19
|
-
- Prefer the expect syntax for assertions to improve readability
|
|
20
|
-
- Keep test code concise; avoid unnecessary complexity or duplication
|
|
21
|
-
- Tests must cover both typical cases and edge cases, including Invalid and error conditions
|
|
22
|
-
- Consider all possible scenarios for each method or behavior and ensure they are tested
|
|
23
|
-
- Do NOT include integration or real world examples
|
|
24
|
-
- Verify all specs are passing
|
data/.cursor/prompts/yardoc.md
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
You are a senior Ruby developer with expert knowledge of YARDoc.
|
|
2
|
-
|
|
3
|
-
Add yardoc to the active tab using the following guidelines:
|
|
4
|
-
|
|
5
|
-
- Follow best practices and implementation
|
|
6
|
-
- New documentation should be consistent with current `lib/cmdx` documentation
|
|
7
|
-
- Examples should be concise, non-repetitive, and realistic
|
|
8
|
-
- Avoid unnecessary complexity or duplication
|
|
9
|
-
- Update any pre-existing documentation to match stated rules
|
|
10
|
-
- Do NOT include `CMDx` module level docs
|
|
11
|
-
- Module level docs description should NOT include `@example`
|
|
12
|
-
- Method level docs should include `@example`, `param`, `@options`, `@return`, and any `@raise`
|
|
13
|
-
- Hash `@params` should expand with possible `@option`
|
|
14
|
-
- Module and method level docs should NOT include `@since`
|
|
15
|
-
- Add RBS inline comments after YARDoc block
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description:
|
|
3
|
-
globs:
|
|
4
|
-
alwaysApply: true
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# Ruby Coding Standards
|
|
8
|
-
|
|
9
|
-
Follow the official Ruby gem guides for best practices.
|
|
10
|
-
Reference the guides outlined in https://guides.rubygems.org
|
|
11
|
-
|
|
12
|
-
## Project Context
|
|
13
|
-
CMDx provides a framework for designing and executing complex business logic within service/command objects.
|
|
14
|
-
Reference the CMDx documentation in https://github.com/drexed/cmdx/blob/main/LLM.md
|
|
15
|
-
|
|
16
|
-
## Technology Stack
|
|
17
|
-
- Ruby 3.4+
|
|
18
|
-
- RSpec 3.1+
|
|
19
|
-
|
|
20
|
-
## Development Guidelines
|
|
21
|
-
- Performance is critical - benchmark any changes that could affect speed
|
|
22
|
-
- Follow existing code patterns and conventions
|
|
23
|
-
- Maintain backward compatibility for public API
|
|
24
|
-
|
|
25
|
-
## Code Style and Structure
|
|
26
|
-
- Write concise, idiomatic Ruby code with accurate examples
|
|
27
|
-
- Follow Ruby conventions and best practices
|
|
28
|
-
- Use object-oriented and functional programming patterns as appropriate
|
|
29
|
-
- Prefer iteration and modularization over code duplication
|
|
30
|
-
- Use descriptive variable and method names (e.g., user_signed_in?, calculate_total)
|
|
31
|
-
- Write comprehensive code documentation using the Yardoc format
|
|
32
|
-
- Minimize object allocations in hot paths
|
|
33
|
-
|
|
34
|
-
## Naming Conventions
|
|
35
|
-
- Use snake_case for file names, method names, and variables
|
|
36
|
-
- Use CamelCase for class and module names
|
|
37
|
-
|
|
38
|
-
## Syntax and Formatting
|
|
39
|
-
- Follow the Ruby Style Guide (https://rubystyle.guide/)
|
|
40
|
-
- Follow Ruby style conventions (2-space indentation, snake_case methods)
|
|
41
|
-
- Use Ruby's expressive syntax (e.g., unless, ||=, &.)
|
|
42
|
-
- Prefer double quotes for strings
|
|
43
|
-
- Respect my Rubocop options
|
|
44
|
-
- Run `bundle exec rubocop .` before finalizing any code changes
|
|
45
|
-
|
|
46
|
-
## Performance Optimization
|
|
47
|
-
- Use memoization for expensive operations
|
|
48
|
-
|
|
49
|
-
## Testing
|
|
50
|
-
- Follow the RSpec Style Guide (https://rspec.rubystyle.guide/)
|
|
51
|
-
- Write comprehensive tests using RSpec
|
|
52
|
-
- It's ok to put multiple assertions in the same example
|
|
53
|
-
- Include both BDD and TDD based tests
|
|
54
|
-
- Create test objects to share across tests
|
|
55
|
-
- Do NOT make tests for obvious or reflective expectations
|
|
56
|
-
- Prefer real objects over mocks. Use `instance_double` if necessary; never `double`
|
|
57
|
-
- Don't test declarative configuration
|
|
58
|
-
- Use appropriate matchers
|
|
59
|
-
- Update tests and update Yardocs after you write code
|
|
60
|
-
- Run `bundle rspec .` before finalizing any code changes
|
|
61
|
-
|
|
62
|
-
## Documentation
|
|
63
|
-
- Utilize the YARDoc format when documenting Ruby code
|
|
64
|
-
- Follow these best practices:
|
|
65
|
-
- Avoid redundant comments that merely restate the code
|
|
66
|
-
- Keep comments up-to-date with code changes
|
|
67
|
-
- Keep documentation consistent
|
|
68
|
-
- Update CHANGELOG.md with any changes
|
data/.irbrc
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "pp"
|
|
4
|
-
|
|
5
|
-
# rubocop:disable Style/MixinUsage
|
|
6
|
-
unless defined?(CMDx)
|
|
7
|
-
require_relative "lib/cmdx"
|
|
8
|
-
|
|
9
|
-
require_relative "spec/support/helpers/task_builders"
|
|
10
|
-
require_relative "spec/support/helpers/workflow_builders"
|
|
11
|
-
include CMDx::Testing::TaskBuilders
|
|
12
|
-
include CMDx::Testing::WorkflowBuilders
|
|
13
|
-
end
|
|
14
|
-
# rubocop:enable Style/MixinUsage
|
|
15
|
-
|
|
16
|
-
def reload!
|
|
17
|
-
exec("irb")
|
|
18
|
-
end
|
data/.rspec
DELETED
data/.rubocop.yml
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
plugins:
|
|
2
|
-
- rubocop-performance
|
|
3
|
-
- rubocop-rake
|
|
4
|
-
- rubocop-rspec
|
|
5
|
-
AllCops:
|
|
6
|
-
NewCops: enable
|
|
7
|
-
DisplayCopNames: true
|
|
8
|
-
DisplayStyleGuide: true
|
|
9
|
-
TargetRubyVersion: 3.1
|
|
10
|
-
Gemspec/DevelopmentDependencies:
|
|
11
|
-
EnforcedStyle: gemspec
|
|
12
|
-
Layout/EmptyLinesAroundAttributeAccessor:
|
|
13
|
-
Enabled: true
|
|
14
|
-
Layout/EmptyLinesAroundClassBody:
|
|
15
|
-
EnforcedStyle: empty_lines_except_namespace
|
|
16
|
-
Layout/EmptyLinesAroundModuleBody:
|
|
17
|
-
EnforcedStyle: empty_lines_except_namespace
|
|
18
|
-
Layout/FirstHashElementIndentation:
|
|
19
|
-
EnforcedStyle: consistent
|
|
20
|
-
Layout/LineLength:
|
|
21
|
-
Enabled: false
|
|
22
|
-
Lint/MissingSuper:
|
|
23
|
-
Exclude:
|
|
24
|
-
- 'spec/**/**/*'
|
|
25
|
-
Lint/ShadowedException:
|
|
26
|
-
Enabled: false
|
|
27
|
-
Lint/UnusedMethodArgument:
|
|
28
|
-
Exclude:
|
|
29
|
-
- 'lib/cmdx/coercions/**/*'
|
|
30
|
-
- 'lib/cmdx/log_formatters/**/*'
|
|
31
|
-
- 'lib/cmdx/middlewares/**/*'
|
|
32
|
-
- 'lib/cmdx/validators/**/*'
|
|
33
|
-
Metrics/AbcSize:
|
|
34
|
-
Enabled: false
|
|
35
|
-
Metrics/BlockLength:
|
|
36
|
-
Enabled: false
|
|
37
|
-
Metrics/ClassLength:
|
|
38
|
-
Enabled: false
|
|
39
|
-
Metrics/CyclomaticComplexity:
|
|
40
|
-
Enabled: false
|
|
41
|
-
Metrics/MethodLength:
|
|
42
|
-
Enabled: false
|
|
43
|
-
Metrics/ModuleLength:
|
|
44
|
-
Enabled: false
|
|
45
|
-
Metrics/PerceivedComplexity:
|
|
46
|
-
Enabled: false
|
|
47
|
-
Naming/MethodParameterName:
|
|
48
|
-
Enabled: false
|
|
49
|
-
RSpec/DescribeClass:
|
|
50
|
-
Exclude:
|
|
51
|
-
- 'spec/integrations/**/*'
|
|
52
|
-
RSpec/ExampleLength:
|
|
53
|
-
Enabled: false
|
|
54
|
-
RSpec/IndexedLet:
|
|
55
|
-
Enabled: false
|
|
56
|
-
RSpec/MessageSpies:
|
|
57
|
-
EnforcedStyle: receive
|
|
58
|
-
RSpec/MultipleExpectations:
|
|
59
|
-
Enabled: false
|
|
60
|
-
RSpec/MultipleMemoizedHelpers:
|
|
61
|
-
Enabled: false
|
|
62
|
-
RSpec/NestedGroups:
|
|
63
|
-
Enabled: false
|
|
64
|
-
RSpec/SpecFilePathFormat:
|
|
65
|
-
CustomTransform:
|
|
66
|
-
CMDx: cmdx
|
|
67
|
-
RSpec/SubjectStub:
|
|
68
|
-
Enabled: false
|
|
69
|
-
RSpec/StubbedMock:
|
|
70
|
-
Enabled: false
|
|
71
|
-
RSpec/VerifiedDoubleReference:
|
|
72
|
-
Enabled: false
|
|
73
|
-
Style/ArgumentsForwarding:
|
|
74
|
-
Exclude:
|
|
75
|
-
- 'lib/cmdx/utils/call.rb'
|
|
76
|
-
Style/CaseEquality:
|
|
77
|
-
Enabled: false
|
|
78
|
-
Style/DocumentDynamicEvalDefinition:
|
|
79
|
-
Enabled: false
|
|
80
|
-
Style/Documentation:
|
|
81
|
-
Enabled: false
|
|
82
|
-
Style/DoubleNegation:
|
|
83
|
-
Enabled: false
|
|
84
|
-
Style/FrozenStringLiteralComment:
|
|
85
|
-
Enabled: true
|
|
86
|
-
EnforcedStyle: always_true
|
|
87
|
-
SafeAutoCorrect: true
|
|
88
|
-
Style/ModuleFunction:
|
|
89
|
-
EnforcedStyle: extend_self
|
|
90
|
-
Style/OptionalBooleanParameter:
|
|
91
|
-
Enabled: false
|
|
92
|
-
Style/StringConcatenation:
|
|
93
|
-
Enabled: false
|
|
94
|
-
Style/StringLiterals:
|
|
95
|
-
EnforcedStyle: double_quotes
|
data/.ruby-version
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
3.4.5
|