taski 0.8.3 → 0.9.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 +52 -0
- data/README.md +108 -50
- data/docs/GUIDE.md +79 -55
- data/examples/README.md +10 -29
- data/examples/clean_demo.rb +25 -65
- data/examples/large_tree_demo.rb +356 -0
- data/examples/message_demo.rb +0 -1
- data/examples/progress_demo.rb +13 -24
- data/examples/reexecution_demo.rb +8 -44
- data/lib/taski/execution/execution_facade.rb +150 -0
- data/lib/taski/execution/executor.rb +167 -359
- data/lib/taski/execution/fiber_protocol.rb +27 -0
- data/lib/taski/execution/registry.rb +15 -19
- data/lib/taski/execution/scheduler.rb +161 -140
- data/lib/taski/execution/task_observer.rb +41 -0
- data/lib/taski/execution/task_output_router.rb +41 -58
- data/lib/taski/execution/task_wrapper.rb +123 -219
- data/lib/taski/execution/worker_pool.rb +279 -64
- data/lib/taski/logging.rb +105 -0
- data/lib/taski/progress/layout/base.rb +600 -0
- data/lib/taski/progress/layout/filters.rb +126 -0
- data/lib/taski/progress/layout/log.rb +27 -0
- data/lib/taski/progress/layout/simple.rb +166 -0
- data/lib/taski/progress/layout/tags.rb +76 -0
- data/lib/taski/progress/layout/theme_drop.rb +84 -0
- data/lib/taski/progress/layout/tree.rb +300 -0
- data/lib/taski/progress/theme/base.rb +224 -0
- data/lib/taski/progress/theme/compact.rb +58 -0
- data/lib/taski/progress/theme/default.rb +25 -0
- data/lib/taski/progress/theme/detail.rb +48 -0
- data/lib/taski/progress/theme/plain.rb +40 -0
- data/lib/taski/static_analysis/analyzer.rb +5 -17
- data/lib/taski/static_analysis/dependency_graph.rb +19 -1
- data/lib/taski/static_analysis/start_dep_analyzer.rb +400 -0
- data/lib/taski/static_analysis/visitor.rb +1 -39
- data/lib/taski/task.rb +49 -58
- data/lib/taski/task_proxy.rb +59 -0
- data/lib/taski/test_helper/errors.rb +1 -1
- data/lib/taski/test_helper.rb +22 -36
- data/lib/taski/version.rb +1 -1
- data/lib/taski.rb +62 -61
- data/sig/taski.rbs +194 -203
- metadata +34 -8
- data/examples/section_demo.rb +0 -195
- data/lib/taski/execution/base_progress_display.rb +0 -393
- data/lib/taski/execution/execution_context.rb +0 -390
- data/lib/taski/execution/plain_progress_display.rb +0 -76
- data/lib/taski/execution/simple_progress_display.rb +0 -247
- data/lib/taski/execution/tree_progress_display.rb +0 -643
- data/lib/taski/section.rb +0 -74
data/examples/clean_demo.rb
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
# This example demonstrates the clean functionality:
|
|
7
7
|
# - Defining clean methods for resource cleanup
|
|
8
8
|
# - Reverse dependency order execution (dependents cleaned before dependencies)
|
|
9
|
-
# -
|
|
9
|
+
# - run_and_clean with block support
|
|
10
10
|
#
|
|
11
11
|
# Run: ruby examples/clean_demo.rb
|
|
12
12
|
|
|
@@ -22,24 +22,14 @@ BUILD_DIR = "/tmp/taski_clean_demo"
|
|
|
22
22
|
class SetupBuildDir < Taski::Task
|
|
23
23
|
exports :build_path
|
|
24
24
|
|
|
25
|
-
##
|
|
26
|
-
# Prepares the task's build directory and simulates its creation.
|
|
27
|
-
#
|
|
28
|
-
# Sets the task's exported `build_path` to the "build" subdirectory under `BUILD_DIR`
|
|
29
|
-
# and performs a simulated creation step with informational output.
|
|
30
25
|
def run
|
|
31
26
|
@build_path = "#{BUILD_DIR}/build"
|
|
32
27
|
puts "[SetupBuildDir] Creating build directory: #{@build_path}"
|
|
33
|
-
# Simulated directory creation
|
|
34
28
|
sleep 0.8
|
|
35
29
|
end
|
|
36
30
|
|
|
37
|
-
##
|
|
38
|
-
# Removes the directory referenced by @build_path.
|
|
39
|
-
# Cleans up build artifacts created by this task.
|
|
40
31
|
def clean
|
|
41
32
|
puts "[SetupBuildDir] Removing build directory: #{@build_path}"
|
|
42
|
-
# Simulated directory removal
|
|
43
33
|
sleep 0.8
|
|
44
34
|
end
|
|
45
35
|
end
|
|
@@ -48,9 +38,6 @@ end
|
|
|
48
38
|
class CompileSource < Taski::Task
|
|
49
39
|
exports :binary_path
|
|
50
40
|
|
|
51
|
-
##
|
|
52
|
-
# Compiles source artifacts and sets the compiled binary path for downstream tasks.
|
|
53
|
-
# This method sets @binary_path to the build directory's "app.bin" file and emits a console message indicating the compilation target.
|
|
54
41
|
def run
|
|
55
42
|
build_dir = SetupBuildDir.build_path
|
|
56
43
|
@binary_path = "#{build_dir}/app.bin"
|
|
@@ -58,9 +45,6 @@ class CompileSource < Taski::Task
|
|
|
58
45
|
sleep 1.5
|
|
59
46
|
end
|
|
60
47
|
|
|
61
|
-
##
|
|
62
|
-
# Removes the compiled binary produced by this task.
|
|
63
|
-
# Performs the task's cleanup step and simulates the deletion process.
|
|
64
48
|
def clean
|
|
65
49
|
puts "[CompileSource] Removing compiled binary: #{@binary_path}"
|
|
66
50
|
sleep 0.6
|
|
@@ -71,11 +55,6 @@ end
|
|
|
71
55
|
class GenerateDocs < Taski::Task
|
|
72
56
|
exports :docs_path
|
|
73
57
|
|
|
74
|
-
##
|
|
75
|
-
# Generates documentation for the build and records the output path.
|
|
76
|
-
#
|
|
77
|
-
# Sets the task's `@docs_path` to the "docs" subdirectory under `SetupBuildDir.build_path`
|
|
78
|
-
# and prints a progress message to STDOUT.
|
|
79
58
|
def run
|
|
80
59
|
build_dir = SetupBuildDir.build_path
|
|
81
60
|
@docs_path = "#{build_dir}/docs"
|
|
@@ -83,9 +62,6 @@ class GenerateDocs < Taski::Task
|
|
|
83
62
|
sleep 1.2
|
|
84
63
|
end
|
|
85
64
|
|
|
86
|
-
##
|
|
87
|
-
# Removes the generated documentation at the task's docs_path.
|
|
88
|
-
# Prints a removal message for @docs_path and simulates its deletion.
|
|
89
65
|
def clean
|
|
90
66
|
puts "[GenerateDocs] Removing generated docs: #{@docs_path}"
|
|
91
67
|
sleep 0.5
|
|
@@ -96,9 +72,6 @@ end
|
|
|
96
72
|
class CreateRelease < Taski::Task
|
|
97
73
|
exports :release_path
|
|
98
74
|
|
|
99
|
-
##
|
|
100
|
-
# Creates the release package path and announces the included artifacts.
|
|
101
|
-
# Uses CompileSource.binary_path and GenerateDocs.docs_path to determine the package inputs, sets @release_path to "#{BUILD_DIR}/release.zip", and prints the binary, docs, and output paths.
|
|
102
75
|
def run
|
|
103
76
|
binary = CompileSource.binary_path
|
|
104
77
|
docs = GenerateDocs.docs_path
|
|
@@ -110,9 +83,6 @@ class CreateRelease < Taski::Task
|
|
|
110
83
|
sleep 0.7
|
|
111
84
|
end
|
|
112
85
|
|
|
113
|
-
##
|
|
114
|
-
# Removes the release package produced by this task.
|
|
115
|
-
# Uses the task's `@release_path` as the target for cleanup.
|
|
116
86
|
def clean
|
|
117
87
|
puts "[CreateRelease] Removing release package: #{@release_path}"
|
|
118
88
|
sleep 0.5
|
|
@@ -123,54 +93,44 @@ puts "\n--- Task Tree Structure ---"
|
|
|
123
93
|
puts CreateRelease.tree
|
|
124
94
|
puts
|
|
125
95
|
|
|
126
|
-
puts "---
|
|
127
|
-
|
|
96
|
+
puts "--- run_and_clean Demo ---"
|
|
97
|
+
puts "The run_and_clean method executes both phases in a single operation."
|
|
98
|
+
puts "Key benefits:"
|
|
99
|
+
puts " - Single progress display session for both phases"
|
|
100
|
+
puts " - Clean always runs, even if run fails (resource release)"
|
|
101
|
+
puts " - Cleaner API for the common use case"
|
|
128
102
|
puts
|
|
129
103
|
|
|
130
|
-
|
|
131
|
-
puts " Release: #{CreateRelease.release_path}"
|
|
132
|
-
puts
|
|
104
|
+
CreateRelease.run_and_clean
|
|
133
105
|
|
|
134
|
-
puts
|
|
135
|
-
puts "
|
|
136
|
-
puts " and finally SetupBuildDir cleans last."
|
|
106
|
+
puts
|
|
107
|
+
puts "Both run and clean phases completed in a single call!"
|
|
137
108
|
puts
|
|
138
109
|
|
|
139
|
-
#
|
|
110
|
+
# Demonstrate block support
|
|
140
111
|
Taski::Task.reset!
|
|
141
112
|
|
|
142
|
-
# Re-run to set up state for clean
|
|
143
|
-
CreateRelease.run
|
|
144
|
-
|
|
145
|
-
puts "\nNow cleaning..."
|
|
146
|
-
CreateRelease.clean
|
|
147
|
-
|
|
148
|
-
puts
|
|
149
|
-
puts "Clean completed! All artifacts removed."
|
|
150
|
-
|
|
151
|
-
puts
|
|
152
113
|
puts "=" * 40
|
|
153
|
-
puts "run_and_clean Demo"
|
|
114
|
+
puts "run_and_clean with Block Demo"
|
|
154
115
|
puts "=" * 40
|
|
155
116
|
puts
|
|
156
|
-
puts "
|
|
157
|
-
puts "
|
|
158
|
-
puts " - Single progress display session for both phases"
|
|
159
|
-
puts " - Clean always runs, even if run fails (resource release)"
|
|
160
|
-
puts " - Cleaner API for the common use case"
|
|
117
|
+
puts "Use a block to execute code between run and clean phases."
|
|
118
|
+
puts "Exported values are accessible within the block."
|
|
161
119
|
puts
|
|
162
120
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
puts "
|
|
167
|
-
puts "
|
|
168
|
-
puts
|
|
169
|
-
|
|
170
|
-
|
|
121
|
+
CreateRelease.run_and_clean do
|
|
122
|
+
puts
|
|
123
|
+
puts "[Block] Release created at: #{CreateRelease.release_path}"
|
|
124
|
+
puts "[Block] Binary: #{CompileSource.binary_path}"
|
|
125
|
+
puts "[Block] Docs: #{GenerateDocs.docs_path}"
|
|
126
|
+
puts "[Block] Deploying release..."
|
|
127
|
+
sleep 0.3
|
|
128
|
+
puts "[Block] Deploy complete!"
|
|
129
|
+
puts
|
|
130
|
+
end
|
|
171
131
|
|
|
172
132
|
puts
|
|
173
|
-
puts "
|
|
133
|
+
puts "Block executed between run and clean phases!"
|
|
174
134
|
puts
|
|
175
135
|
|
|
176
136
|
# Demonstrate error handling
|
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
# Demo: Large tree to test rendering performance
|
|
5
|
+
# Run with: ruby examples/large_tree_demo.rb
|
|
6
|
+
|
|
7
|
+
require_relative "../lib/taski"
|
|
8
|
+
|
|
9
|
+
# Leaf tasks (Layer 4) - 16 tasks
|
|
10
|
+
class Leaf01 < Taski::Task
|
|
11
|
+
exports :value
|
|
12
|
+
def run
|
|
13
|
+
puts "Leaf01: Starting..."
|
|
14
|
+
sleep(rand(0.1..0.3))
|
|
15
|
+
puts "Leaf01: Done!"
|
|
16
|
+
@value = "leaf01"
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
class Leaf02 < Taski::Task
|
|
21
|
+
exports :value
|
|
22
|
+
def run
|
|
23
|
+
puts "Leaf02: Starting..."
|
|
24
|
+
sleep(rand(0.1..0.3))
|
|
25
|
+
puts "Leaf02: Done!"
|
|
26
|
+
@value = "leaf02"
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
class Leaf03 < Taski::Task
|
|
31
|
+
exports :value
|
|
32
|
+
def run
|
|
33
|
+
puts "Leaf03: Starting..."
|
|
34
|
+
sleep(rand(0.1..0.3))
|
|
35
|
+
puts "Leaf03: Done!"
|
|
36
|
+
@value = "leaf03"
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
class Leaf04 < Taski::Task
|
|
41
|
+
exports :value
|
|
42
|
+
def run
|
|
43
|
+
puts "Leaf04: Starting..."
|
|
44
|
+
sleep(rand(0.1..0.3))
|
|
45
|
+
puts "Leaf04: Done!"
|
|
46
|
+
@value = "leaf04"
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
class Leaf05 < Taski::Task
|
|
51
|
+
exports :value
|
|
52
|
+
def run
|
|
53
|
+
puts "Leaf05: Starting..."
|
|
54
|
+
sleep(rand(0.1..0.3))
|
|
55
|
+
puts "Leaf05: Done!"
|
|
56
|
+
@value = "leaf05"
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
class Leaf06 < Taski::Task
|
|
61
|
+
exports :value
|
|
62
|
+
def run
|
|
63
|
+
puts "Leaf06: Starting..."
|
|
64
|
+
sleep(rand(0.1..0.3))
|
|
65
|
+
puts "Leaf06: Done!"
|
|
66
|
+
@value = "leaf06"
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
class Leaf07 < Taski::Task
|
|
71
|
+
exports :value
|
|
72
|
+
def run
|
|
73
|
+
puts "Leaf07: Starting..."
|
|
74
|
+
sleep(rand(0.1..0.3))
|
|
75
|
+
puts "Leaf07: Done!"
|
|
76
|
+
@value = "leaf07"
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
class Leaf08 < Taski::Task
|
|
81
|
+
exports :value
|
|
82
|
+
def run
|
|
83
|
+
puts "Leaf08: Starting..."
|
|
84
|
+
sleep(rand(0.1..0.3))
|
|
85
|
+
puts "Leaf08: Done!"
|
|
86
|
+
@value = "leaf08"
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
class Leaf09 < Taski::Task
|
|
91
|
+
exports :value
|
|
92
|
+
def run
|
|
93
|
+
puts "Leaf09: Starting..."
|
|
94
|
+
sleep(rand(0.1..0.3))
|
|
95
|
+
puts "Leaf09: Done!"
|
|
96
|
+
@value = "leaf09"
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
class Leaf10 < Taski::Task
|
|
101
|
+
exports :value
|
|
102
|
+
def run
|
|
103
|
+
puts "Leaf10: Starting..."
|
|
104
|
+
sleep(rand(0.1..0.3))
|
|
105
|
+
puts "Leaf10: Done!"
|
|
106
|
+
@value = "leaf10"
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
class Leaf11 < Taski::Task
|
|
111
|
+
exports :value
|
|
112
|
+
def run
|
|
113
|
+
puts "Leaf11: Starting..."
|
|
114
|
+
sleep(rand(0.1..0.3))
|
|
115
|
+
puts "Leaf11: Done!"
|
|
116
|
+
@value = "leaf11"
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
class Leaf12 < Taski::Task
|
|
121
|
+
exports :value
|
|
122
|
+
def run
|
|
123
|
+
puts "Leaf12: Starting..."
|
|
124
|
+
sleep(rand(0.1..0.3))
|
|
125
|
+
puts "Leaf12: Done!"
|
|
126
|
+
@value = "leaf12"
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
class Leaf13 < Taski::Task
|
|
131
|
+
exports :value
|
|
132
|
+
def run
|
|
133
|
+
puts "Leaf13: Starting..."
|
|
134
|
+
sleep(rand(0.1..0.3))
|
|
135
|
+
puts "Leaf13: Done!"
|
|
136
|
+
@value = "leaf13"
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
class Leaf14 < Taski::Task
|
|
141
|
+
exports :value
|
|
142
|
+
def run
|
|
143
|
+
puts "Leaf14: Starting..."
|
|
144
|
+
sleep(rand(0.1..0.3))
|
|
145
|
+
puts "Leaf14: Done!"
|
|
146
|
+
@value = "leaf14"
|
|
147
|
+
end
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
class Leaf15 < Taski::Task
|
|
151
|
+
exports :value
|
|
152
|
+
def run
|
|
153
|
+
puts "Leaf15: Starting..."
|
|
154
|
+
sleep(rand(0.1..0.3))
|
|
155
|
+
puts "Leaf15: Done!"
|
|
156
|
+
@value = "leaf15"
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
class Leaf16 < Taski::Task
|
|
161
|
+
exports :value
|
|
162
|
+
def run
|
|
163
|
+
puts "Leaf16: Starting..."
|
|
164
|
+
sleep(rand(0.1..0.3))
|
|
165
|
+
puts "Leaf16: Done!"
|
|
166
|
+
@value = "leaf16"
|
|
167
|
+
end
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
# Middle tasks (Layer 3) - 8 tasks, each depends on 2 leaves
|
|
171
|
+
class Middle01 < Taski::Task
|
|
172
|
+
exports :value
|
|
173
|
+
def run
|
|
174
|
+
puts "Middle01: Aggregating leaves..."
|
|
175
|
+
Leaf01.value
|
|
176
|
+
Leaf02.value
|
|
177
|
+
sleep(0.05)
|
|
178
|
+
puts "Middle01: Complete"
|
|
179
|
+
@value = "middle01"
|
|
180
|
+
end
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
class Middle02 < Taski::Task
|
|
184
|
+
exports :value
|
|
185
|
+
def run
|
|
186
|
+
puts "Middle02: Aggregating leaves..."
|
|
187
|
+
Leaf03.value
|
|
188
|
+
Leaf04.value
|
|
189
|
+
sleep(0.05)
|
|
190
|
+
puts "Middle02: Complete"
|
|
191
|
+
@value = "middle02"
|
|
192
|
+
end
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
class Middle03 < Taski::Task
|
|
196
|
+
exports :value
|
|
197
|
+
def run
|
|
198
|
+
puts "Middle03: Aggregating leaves..."
|
|
199
|
+
Leaf05.value
|
|
200
|
+
Leaf06.value
|
|
201
|
+
sleep(0.05)
|
|
202
|
+
puts "Middle03: Complete"
|
|
203
|
+
@value = "middle03"
|
|
204
|
+
end
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
class Middle04 < Taski::Task
|
|
208
|
+
exports :value
|
|
209
|
+
def run
|
|
210
|
+
puts "Middle04: Aggregating leaves..."
|
|
211
|
+
Leaf07.value
|
|
212
|
+
Leaf08.value
|
|
213
|
+
sleep(0.05)
|
|
214
|
+
puts "Middle04: Complete"
|
|
215
|
+
@value = "middle04"
|
|
216
|
+
end
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
class Middle05 < Taski::Task
|
|
220
|
+
exports :value
|
|
221
|
+
def run
|
|
222
|
+
puts "Middle05: Aggregating leaves..."
|
|
223
|
+
Leaf09.value
|
|
224
|
+
Leaf10.value
|
|
225
|
+
sleep(0.05)
|
|
226
|
+
puts "Middle05: Complete"
|
|
227
|
+
@value = "middle05"
|
|
228
|
+
end
|
|
229
|
+
end
|
|
230
|
+
|
|
231
|
+
class Middle06 < Taski::Task
|
|
232
|
+
exports :value
|
|
233
|
+
def run
|
|
234
|
+
puts "Middle06: Aggregating leaves..."
|
|
235
|
+
Leaf11.value
|
|
236
|
+
Leaf12.value
|
|
237
|
+
sleep(0.05)
|
|
238
|
+
puts "Middle06: Complete"
|
|
239
|
+
@value = "middle06"
|
|
240
|
+
end
|
|
241
|
+
end
|
|
242
|
+
|
|
243
|
+
class Middle07 < Taski::Task
|
|
244
|
+
exports :value
|
|
245
|
+
def run
|
|
246
|
+
puts "Middle07: Aggregating leaves..."
|
|
247
|
+
Leaf13.value
|
|
248
|
+
Leaf14.value
|
|
249
|
+
sleep(0.05)
|
|
250
|
+
puts "Middle07: Complete"
|
|
251
|
+
@value = "middle07"
|
|
252
|
+
end
|
|
253
|
+
end
|
|
254
|
+
|
|
255
|
+
class Middle08 < Taski::Task
|
|
256
|
+
exports :value
|
|
257
|
+
def run
|
|
258
|
+
puts "Middle08: Aggregating leaves..."
|
|
259
|
+
Leaf15.value
|
|
260
|
+
Leaf16.value
|
|
261
|
+
sleep(0.05)
|
|
262
|
+
puts "Middle08: Complete"
|
|
263
|
+
@value = "middle08"
|
|
264
|
+
end
|
|
265
|
+
end
|
|
266
|
+
|
|
267
|
+
# Top tasks (Layer 2) - 4 tasks, each depends on 2 middles
|
|
268
|
+
class Top01 < Taski::Task
|
|
269
|
+
exports :value
|
|
270
|
+
def run
|
|
271
|
+
Middle01.value
|
|
272
|
+
Middle02.value
|
|
273
|
+
sleep(0.05)
|
|
274
|
+
@value = "top01"
|
|
275
|
+
end
|
|
276
|
+
end
|
|
277
|
+
|
|
278
|
+
class Top02 < Taski::Task
|
|
279
|
+
exports :value
|
|
280
|
+
def run
|
|
281
|
+
Middle03.value
|
|
282
|
+
Middle04.value
|
|
283
|
+
sleep(0.05)
|
|
284
|
+
@value = "top02"
|
|
285
|
+
end
|
|
286
|
+
end
|
|
287
|
+
|
|
288
|
+
class Top03 < Taski::Task
|
|
289
|
+
exports :value
|
|
290
|
+
def run
|
|
291
|
+
Middle05.value
|
|
292
|
+
Middle06.value
|
|
293
|
+
sleep(0.05)
|
|
294
|
+
@value = "top03"
|
|
295
|
+
end
|
|
296
|
+
end
|
|
297
|
+
|
|
298
|
+
class Top04 < Taski::Task
|
|
299
|
+
exports :value
|
|
300
|
+
def run
|
|
301
|
+
Middle07.value
|
|
302
|
+
Middle08.value
|
|
303
|
+
sleep(0.05)
|
|
304
|
+
@value = "top04"
|
|
305
|
+
end
|
|
306
|
+
end
|
|
307
|
+
|
|
308
|
+
# Branch tasks (Layer 1) - 2 tasks, each depends on 2 tops
|
|
309
|
+
class Branch01 < Taski::Task
|
|
310
|
+
exports :value
|
|
311
|
+
def run
|
|
312
|
+
Top01.value
|
|
313
|
+
Top02.value
|
|
314
|
+
sleep(0.05)
|
|
315
|
+
@value = "branch01"
|
|
316
|
+
end
|
|
317
|
+
end
|
|
318
|
+
|
|
319
|
+
class Branch02 < Taski::Task
|
|
320
|
+
exports :value
|
|
321
|
+
def run
|
|
322
|
+
Top03.value
|
|
323
|
+
Top04.value
|
|
324
|
+
sleep(0.05)
|
|
325
|
+
@value = "branch02"
|
|
326
|
+
end
|
|
327
|
+
end
|
|
328
|
+
|
|
329
|
+
# Root task (Layer 0)
|
|
330
|
+
class LargeTreeRoot < Taski::Task
|
|
331
|
+
exports :result
|
|
332
|
+
|
|
333
|
+
def run
|
|
334
|
+
Branch01.value
|
|
335
|
+
Branch02.value
|
|
336
|
+
sleep(0.05)
|
|
337
|
+
@result = "done"
|
|
338
|
+
end
|
|
339
|
+
end
|
|
340
|
+
|
|
341
|
+
puts "Large Tree Demo"
|
|
342
|
+
puts "==============="
|
|
343
|
+
puts "Tree structure: 1 root -> 2 branch -> 4 top -> 8 middle -> 16 leaf (31 total)"
|
|
344
|
+
puts
|
|
345
|
+
puts "Static tree:"
|
|
346
|
+
puts LargeTreeRoot.tree
|
|
347
|
+
puts
|
|
348
|
+
puts "Running with progress display..."
|
|
349
|
+
puts
|
|
350
|
+
|
|
351
|
+
Taski.progress_display = Taski::Progress::Layout::Tree.new
|
|
352
|
+
LargeTreeRoot.reset!
|
|
353
|
+
result = LargeTreeRoot.result
|
|
354
|
+
|
|
355
|
+
puts
|
|
356
|
+
puts "Result: #{result}"
|
data/examples/message_demo.rb
CHANGED
data/examples/progress_demo.rb
CHANGED
|
@@ -4,13 +4,11 @@
|
|
|
4
4
|
# Taski Progress Display Demo
|
|
5
5
|
#
|
|
6
6
|
# This example demonstrates the progress display modes:
|
|
7
|
-
# -
|
|
8
|
-
# -
|
|
7
|
+
# - Simple mode (default): One-line spinner with current task name
|
|
8
|
+
# - Tree mode: Shows task hierarchy with real-time updates
|
|
9
9
|
#
|
|
10
10
|
# Run:
|
|
11
|
-
# ruby examples/progress_demo.rb #
|
|
12
|
-
# TASKI_PROGRESS_MODE=simple ruby examples/progress_demo.rb # Simple mode
|
|
13
|
-
# TASKI_PROGRESS_DISABLE=1 ruby examples/progress_demo.rb # No progress
|
|
11
|
+
# ruby examples/progress_demo.rb # Simple mode (default)
|
|
14
12
|
#
|
|
15
13
|
# Covers:
|
|
16
14
|
# - Parallel task execution with progress display
|
|
@@ -20,24 +18,16 @@
|
|
|
20
18
|
|
|
21
19
|
require_relative "../lib/taski"
|
|
22
20
|
|
|
23
|
-
# Configuration
|
|
24
|
-
class
|
|
25
|
-
|
|
21
|
+
# Configuration task with conditional logic
|
|
22
|
+
class DatabaseConfig < Taski::Task
|
|
23
|
+
exports :connection_string
|
|
26
24
|
|
|
27
|
-
def
|
|
28
|
-
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
class ProductionDB < Taski::Task
|
|
32
|
-
def run
|
|
25
|
+
def run
|
|
26
|
+
if ENV["USE_PROD_DB"] == "1"
|
|
33
27
|
puts "Connecting to production database..."
|
|
34
28
|
sleep(0.4)
|
|
35
29
|
@connection_string = "postgresql://prod-server:5432/myapp"
|
|
36
|
-
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
class DevelopmentDB < Taski::Task
|
|
40
|
-
def run
|
|
30
|
+
else
|
|
41
31
|
puts "Connecting to development database..."
|
|
42
32
|
sleep(0.3)
|
|
43
33
|
@connection_string = "postgresql://localhost:5432/myapp_dev"
|
|
@@ -109,7 +99,7 @@ class BuildApplication < Taski::Task
|
|
|
109
99
|
exports :result
|
|
110
100
|
|
|
111
101
|
def run
|
|
112
|
-
db =
|
|
102
|
+
db = DatabaseConfig.connection_string
|
|
113
103
|
layers = ExtractLayers.extracted_data
|
|
114
104
|
RunSystemCommand.command_result
|
|
115
105
|
|
|
@@ -129,7 +119,7 @@ end
|
|
|
129
119
|
# Main execution
|
|
130
120
|
puts "Taski Progress Display Demo"
|
|
131
121
|
puts "=" * 50
|
|
132
|
-
puts "Progress
|
|
122
|
+
puts "Progress display: #{Taski.progress_display.class}"
|
|
133
123
|
puts
|
|
134
124
|
|
|
135
125
|
puts "Task Tree Structure:"
|
|
@@ -149,6 +139,5 @@ puts "=" * 50
|
|
|
149
139
|
puts "Execution completed!"
|
|
150
140
|
puts "Result: #{result.inspect}"
|
|
151
141
|
puts
|
|
152
|
-
puts "
|
|
153
|
-
puts "
|
|
154
|
-
puts " TASKI_PROGRESS_DISABLE=1 ruby examples/progress_demo.rb"
|
|
142
|
+
puts "To use tree mode, add before execution:"
|
|
143
|
+
puts " Taski.progress_display = Taski::Progress::Layout::Tree.new"
|
|
@@ -5,10 +5,9 @@
|
|
|
5
5
|
#
|
|
6
6
|
# This example demonstrates the execution model:
|
|
7
7
|
# - Task.run / Task.value: Fresh execution every time
|
|
8
|
-
# - Task.new.run: Instance-level caching
|
|
9
8
|
# - Dependencies within same execution scope share results
|
|
10
9
|
#
|
|
11
|
-
# Run:
|
|
10
|
+
# Run: ruby examples/reexecution_demo.rb
|
|
12
11
|
|
|
13
12
|
require_relative "../lib/taski"
|
|
14
13
|
|
|
@@ -65,37 +64,7 @@ puts " => #{value2}"
|
|
|
65
64
|
puts "\nValues are different: #{value1 != value2}"
|
|
66
65
|
|
|
67
66
|
puts "\n" + "=" * 50
|
|
68
|
-
puts "\n2.
|
|
69
|
-
puts "-" * 50
|
|
70
|
-
puts "Same instance caches the result:"
|
|
71
|
-
|
|
72
|
-
instance = RandomGenerator.new
|
|
73
|
-
puts "\nFirst run on instance:"
|
|
74
|
-
result1 = instance.run
|
|
75
|
-
puts " instance.value = #{instance.value}"
|
|
76
|
-
|
|
77
|
-
puts "\nSecond run on same instance (returns cached):"
|
|
78
|
-
result2 = instance.run
|
|
79
|
-
puts " instance.value = #{instance.value}"
|
|
80
|
-
|
|
81
|
-
puts "\nSame result: #{result1 == result2}"
|
|
82
|
-
|
|
83
|
-
puts "\n" + "=" * 50
|
|
84
|
-
puts "\n3. Different Instances: Independent Executions"
|
|
85
|
-
puts "-" * 50
|
|
86
|
-
|
|
87
|
-
instance1 = RandomGenerator.new
|
|
88
|
-
instance1.run
|
|
89
|
-
puts "instance1.value = #{instance1.value}"
|
|
90
|
-
|
|
91
|
-
instance2 = RandomGenerator.new
|
|
92
|
-
instance2.run
|
|
93
|
-
puts "instance2.value = #{instance2.value}"
|
|
94
|
-
|
|
95
|
-
puts "\nDifferent values: #{instance1.value != instance2.value}"
|
|
96
|
-
|
|
97
|
-
puts "\n" + "=" * 50
|
|
98
|
-
puts "\n4. Scope-Based Caching for Dependencies"
|
|
67
|
+
puts "\n2. Scope-Based Caching for Dependencies"
|
|
99
68
|
puts "-" * 50
|
|
100
69
|
puts "Within ONE execution, dependencies are cached:"
|
|
101
70
|
|
|
@@ -106,7 +75,7 @@ puts "\nNote: Both accesses return the SAME value!"
|
|
|
106
75
|
puts "(Because they're in the same execution scope)"
|
|
107
76
|
|
|
108
77
|
puts "\n" + "=" * 50
|
|
109
|
-
puts "\
|
|
78
|
+
puts "\n3. Dependency Chain with Fresh Execution"
|
|
110
79
|
puts "-" * 50
|
|
111
80
|
|
|
112
81
|
puts "Each Consumer.run creates fresh RandomGenerator:"
|
|
@@ -117,7 +86,7 @@ puts "\nSecond Consumer.run (different RandomGenerator value):"
|
|
|
117
86
|
Consumer.run
|
|
118
87
|
|
|
119
88
|
puts "\n" + "=" * 50
|
|
120
|
-
puts "\
|
|
89
|
+
puts "\n4. Use Cases Summary"
|
|
121
90
|
puts "-" * 50
|
|
122
91
|
puts <<~SUMMARY
|
|
123
92
|
TaskClass.run / TaskClass.value
|
|
@@ -125,15 +94,10 @@ puts <<~SUMMARY
|
|
|
125
94
|
=> Dependencies within same execution are cached
|
|
126
95
|
=> Use for: Independent executions, scripts
|
|
127
96
|
|
|
128
|
-
TaskClass.
|
|
129
|
-
=>
|
|
130
|
-
=>
|
|
131
|
-
=> Use for: Re-
|
|
132
|
-
|
|
133
|
-
instance.reset!
|
|
134
|
-
=> Clears instance cache
|
|
135
|
-
=> Next .run will execute fresh
|
|
136
|
-
=> Use for: Re-running same instance
|
|
97
|
+
TaskClass.reset!
|
|
98
|
+
=> Clears task state
|
|
99
|
+
=> Next execution starts fresh
|
|
100
|
+
=> Use for: Re-running tasks in tests
|
|
137
101
|
SUMMARY
|
|
138
102
|
|
|
139
103
|
puts "\n" + "=" * 50
|