cmdx 1.7.0 → 1.7.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/LLM.md +16 -0
- data/docs/outcomes/result.md +17 -0
- data/lib/cmdx/task.rb +7 -6
- data/lib/cmdx/version.rb +1 -1
- 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: 9bbf1d8db7665b82da9af2dd5e017977945bbd550700177368b1363a8e63275e
|
4
|
+
data.tar.gz: 0f1720432a999ff31399d67c602e5277ee8cb1a8062117165c425a39233eb81c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 144c01abf663258e34b40eaa9e1deba09b59347b97773237f9bd84f5d82474825aca38f21b6ad0c052f1b058f6a5550e24ef8f3598da4cdecad94da1689bea5c
|
7
|
+
data.tar.gz: 25220966f85607b73740107b5af5da7889e75592055ad17156bc48f157550e2d030f542b7f279ec731cbb78ef732be1c6507b8e448a97a8324749d4746549d95
|
data/CHANGELOG.md
CHANGED
data/LLM.md
CHANGED
@@ -1251,6 +1251,22 @@ result.index #=> 0 (first task in chain)
|
|
1251
1251
|
result.chain.results[result.index] == result #=> true
|
1252
1252
|
```
|
1253
1253
|
|
1254
|
+
## Block Yield
|
1255
|
+
|
1256
|
+
Implement conditional logic using a block expression that yields a result for complete encapsulation.
|
1257
|
+
|
1258
|
+
```ruby
|
1259
|
+
BuildApplication.execute(version: "1.2.3") do |result|
|
1260
|
+
if result.success?
|
1261
|
+
notify_deployment_ready(result)
|
1262
|
+
elsif result.failed?
|
1263
|
+
handle_build_failure(result)
|
1264
|
+
else
|
1265
|
+
log_skip_reason(result)
|
1266
|
+
end
|
1267
|
+
end
|
1268
|
+
```
|
1269
|
+
|
1254
1270
|
## Handlers
|
1255
1271
|
|
1256
1272
|
Use result handlers for clean, functional-style conditional logic. Handlers return the result object, enabling method chaining and fluent interfaces.
|
data/docs/outcomes/result.md
CHANGED
@@ -9,6 +9,7 @@ The result object is the comprehensive return value of task execution, providing
|
|
9
9
|
- [Outcome Analysis](#outcome-analysis)
|
10
10
|
- [Chain Analysis](#chain-analysis)
|
11
11
|
- [Index and Position](#index-and-position)
|
12
|
+
- [Block Yield](#block-yield)
|
12
13
|
- [Handlers](#handlers)
|
13
14
|
- [Pattern Matching](#pattern-matching)
|
14
15
|
- [Array Pattern](#array-pattern)
|
@@ -113,6 +114,22 @@ result.index #=> 0 (first task in chain)
|
|
113
114
|
result.chain.results[result.index] == result #=> true
|
114
115
|
```
|
115
116
|
|
117
|
+
## Block Yield
|
118
|
+
|
119
|
+
Implement conditional logic using a block expression that yields a result for complete encapsulation.
|
120
|
+
|
121
|
+
```ruby
|
122
|
+
BuildApplication.execute(version: "1.2.3") do |result|
|
123
|
+
if result.success?
|
124
|
+
notify_deployment_ready(result)
|
125
|
+
elsif result.failed?
|
126
|
+
handle_build_failure(result)
|
127
|
+
else
|
128
|
+
log_skip_reason(result)
|
129
|
+
end
|
130
|
+
end
|
131
|
+
```
|
132
|
+
|
116
133
|
## Handlers
|
117
134
|
|
118
135
|
Use result handlers for clean, functional-style conditional logic. Handlers return the result object, enabling method chaining and fluent interfaces.
|
data/lib/cmdx/task.rb
CHANGED
@@ -169,10 +169,10 @@ module CMDx
|
|
169
169
|
# if result.success?
|
170
170
|
# puts "Task completed successfully"
|
171
171
|
# end
|
172
|
-
def execute(
|
173
|
-
task = new(
|
172
|
+
def execute(*args, **kwargs)
|
173
|
+
task = new(*args, **kwargs)
|
174
174
|
task.execute(raise: false)
|
175
|
-
task.result
|
175
|
+
block_given? ? yield(task.result) : task.result
|
176
176
|
end
|
177
177
|
|
178
178
|
# @param args [Array] Arguments to pass to the task constructor
|
@@ -184,10 +184,10 @@ module CMDx
|
|
184
184
|
# @example
|
185
185
|
# result = MyTask.execute!(name: "example")
|
186
186
|
# # Will raise an exception if execution fails
|
187
|
-
def execute!(
|
188
|
-
task = new(
|
187
|
+
def execute!(*args, **kwargs)
|
188
|
+
task = new(*args, **kwargs)
|
189
189
|
task.execute(raise: true)
|
190
|
-
task.result
|
190
|
+
block_given? ? yield(task.result) : task.result
|
191
191
|
end
|
192
192
|
|
193
193
|
end
|
@@ -201,6 +201,7 @@ module CMDx
|
|
201
201
|
# result = task.execute(raise: true)
|
202
202
|
def execute(raise: false)
|
203
203
|
Executor.execute(self, raise:)
|
204
|
+
block_given? ? yield(result) : result
|
204
205
|
end
|
205
206
|
|
206
207
|
# @raise [UndefinedMethodError] Always raised as this method must be overridden
|
data/lib/cmdx/version.rb
CHANGED