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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8483d78b67a6dfffa6721b39e623ac08d57d443b499287891bfb9c6e06422c89
4
- data.tar.gz: 02cb722299d6a97fb4e2d07a84880c7374a8c17b691f42bee995bd4f3ea698ab
3
+ metadata.gz: 9bbf1d8db7665b82da9af2dd5e017977945bbd550700177368b1363a8e63275e
4
+ data.tar.gz: 0f1720432a999ff31399d67c602e5277ee8cb1a8062117165c425a39233eb81c
5
5
  SHA512:
6
- metadata.gz: b6600b6d617c11a3ec3b66367a7fa309e191bd2d1f20a3fb1a538565a0c2b45e05f8093f2c3e07edbb155e308e6c90c486f069db171aac68e8658bbe85bd4b34
7
- data.tar.gz: 6ad4a1348066d3aa4d0ed2733fc88f94af293835cc970be5986f3c002cf3b3615f474bff774a2b48f7e043920ca01b5f278cd26850b5b4827a70d2a4b0e6ab50
6
+ metadata.gz: 144c01abf663258e34b40eaa9e1deba09b59347b97773237f9bd84f5d82474825aca38f21b6ad0c052f1b058f6a5550e24ef8f3598da4cdecad94da1689bea5c
7
+ data.tar.gz: 25220966f85607b73740107b5af5da7889e75592055ad17156bc48f157550e2d030f542b7f279ec731cbb78ef732be1c6507b8e448a97a8324749d4746549d95
data/CHANGELOG.md CHANGED
@@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
 
7
7
  ## [TODO]
8
8
 
9
+ ## [1.7.1] - 2025-08-26
10
+
11
+ ### Added
12
+ - Yield result if block given to `execute` and `execute!` methods
13
+
9
14
  ## [1.7.0] - 2025-08-25
10
15
 
11
16
  ### Added
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.
@@ -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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module CMDx
4
4
 
5
- VERSION = "1.7.0"
5
+ VERSION = "1.7.1"
6
6
 
7
7
  end
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.7.0
4
+ version: 1.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juan Gomez