taski 0.8.1 → 0.8.2

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.
@@ -1,72 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require_relative "../lib/taski"
5
-
6
- # Demo tasks that simulate parallel execution with progress display
7
- # Run with: ruby examples/parallel_progress_demo.rb
8
-
9
- class DownloadLayer1 < Taski::Task
10
- exports :layer1_data
11
-
12
- def run
13
- sleep(2.3) # Simulate download
14
- @layer1_data = "Layer 1 data (base image)"
15
- end
16
- end
17
-
18
- class DownloadLayer2 < Taski::Task
19
- exports :layer2_data
20
-
21
- def run
22
- sleep(5.5) # Simulate slower download
23
- @layer2_data = "Layer 2 data (dependencies)"
24
- end
25
- end
26
-
27
- class DownloadLayer3 < Taski::Task
28
- exports :layer3_data
29
-
30
- def run
31
- sleep(0.2) # Simulate fast download
32
- @layer3_data = "Layer 3 data (application)"
33
- end
34
- end
35
-
36
- class ExtractLayers < Taski::Task
37
- exports :extracted_data
38
-
39
- def run
40
- # This task depends on all download tasks (via static analysis)
41
- layer1 = DownloadLayer1.layer1_data
42
- layer2 = DownloadLayer2.layer2_data
43
- layer3 = DownloadLayer3.layer3_data
44
-
45
- sleep(0.3) # Simulate extraction
46
- @extracted_data = "Extracted: #{layer1}, #{layer2}, #{layer3}"
47
- end
48
- end
49
-
50
- class VerifyImage < Taski::Task
51
- exports :verification_result
52
-
53
- def run
54
- # Depends on ExtractLayers
55
- data = ExtractLayers.extracted_data
56
-
57
- sleep(0.2) # Simulate verification
58
- @verification_result = "Verified: #{data}"
59
- end
60
- end
61
-
62
- # Start progress display
63
- Taski.progress_display&.start
64
-
65
- # Execute the final task (all dependencies will be resolved automatically)
66
- result = VerifyImage.verification_result
67
-
68
- # Stop progress display
69
- Taski.progress_display&.stop
70
-
71
- puts "\n\nFinal result:"
72
- puts result
@@ -1,80 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require_relative "../lib/taski"
5
-
6
- # Demo of simple one-line progress display mode
7
- # Run with: TASKI_PROGRESS_MODE=simple ruby examples/simple_progress_demo.rb
8
- # Or set via API: Taski.progress_mode = :simple
9
-
10
- # Set simple progress mode via API
11
- Taski.progress_mode = :simple
12
-
13
- class DownloadLayer1 < Taski::Task
14
- exports :layer1_data
15
-
16
- def run
17
- puts "Downloading base image..."
18
- sleep(0.8)
19
- puts "Base image complete"
20
- @layer1_data = "Layer 1 data (base image)"
21
- end
22
- end
23
-
24
- class DownloadLayer2 < Taski::Task
25
- exports :layer2_data
26
-
27
- def run
28
- puts "Downloading dependencies..."
29
- sleep(1.2)
30
- puts "Dependencies complete"
31
- @layer2_data = "Layer 2 data (dependencies)"
32
- end
33
- end
34
-
35
- class DownloadLayer3 < Taski::Task
36
- exports :layer3_data
37
-
38
- def run
39
- puts "Downloading application..."
40
- sleep(0.3)
41
- puts "Application complete"
42
- @layer3_data = "Layer 3 data (application)"
43
- end
44
- end
45
-
46
- class ExtractLayers < Taski::Task
47
- exports :extracted_data
48
-
49
- def run
50
- layer1 = DownloadLayer1.layer1_data
51
- layer2 = DownloadLayer2.layer2_data
52
- layer3 = DownloadLayer3.layer3_data
53
-
54
- puts "Extracting layers..."
55
- sleep(0.3)
56
- @extracted_data = "Extracted: #{layer1}, #{layer2}, #{layer3}"
57
- end
58
- end
59
-
60
- class VerifyImage < Taski::Task
61
- exports :verification_result
62
-
63
- def run
64
- data = ExtractLayers.extracted_data
65
-
66
- puts "Verifying image..."
67
- sleep(0.2)
68
- @verification_result = "Verified: #{data}"
69
- end
70
- end
71
-
72
- puts "=== Simple Progress Display Demo ==="
73
- puts "Progress mode: #{Taski.progress_mode}"
74
- puts ""
75
-
76
- # Execute the final task (all dependencies will be resolved automatically)
77
- result = VerifyImage.verification_result
78
-
79
- puts "\n\nFinal result:"
80
- puts result
@@ -1,56 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require_relative "../lib/taski"
5
-
6
- # Demo: Subprocess output capture with system()
7
- #
8
- # This example demonstrates how Taski captures output from system() calls
9
- # and displays them in the progress spinner.
10
- # Run with: ruby examples/system_call_demo.rb
11
-
12
- class SlowOutputTask < Taski::Task
13
- exports :success
14
-
15
- def run
16
- puts "Running command with streaming output..."
17
- # Use a command that produces output over time
18
- @success = system("for i in 1 2 3 4 5; do echo \"Processing step $i...\"; sleep 0.3; done")
19
- end
20
- end
21
-
22
- class AnotherSlowTask < Taski::Task
23
- exports :result
24
-
25
- def run
26
- puts "Running another slow command..."
27
- @result = system("for i in A B C; do echo \"Stage $i complete\"; sleep 0.4; done")
28
- end
29
- end
30
-
31
- class MainTask < Taski::Task
32
- exports :summary
33
-
34
- def run
35
- puts "Starting main task..."
36
- slow1 = SlowOutputTask.success
37
- slow2 = AnotherSlowTask.result
38
- @summary = {slow1: slow1, slow2: slow2}
39
- puts "All done!"
40
- end
41
- end
42
-
43
- puts "=" * 60
44
- puts "Subprocess Output Capture Demo"
45
- puts "Watch the spinner show system() output in real-time!"
46
- puts "=" * 60
47
- puts
48
-
49
- Taski.progress_display&.start
50
- result = MainTask.summary
51
- Taski.progress_display&.stop
52
-
53
- puts
54
- puts "=" * 60
55
- puts "Result: #{result.inspect}"
56
- puts "=" * 60
@@ -1,164 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require_relative "../lib/taski"
5
-
6
- # Demo for tree-based progress display
7
- # Run with: ruby examples/tree_progress_demo.rb
8
-
9
- # Database configuration section with multiple impl candidates
10
- class DatabaseSection < Taski::Section
11
- interfaces :connection_string
12
-
13
- def impl
14
- if ENV["USE_PROD_DB"] == "1"
15
- ProductionDB
16
- else
17
- DevelopmentDB
18
- end
19
- end
20
-
21
- class ProductionDB < Taski::Task
22
- def run
23
- puts "Connecting to production database..."
24
- sleep(0.5)
25
- puts "Production DB connected"
26
- @connection_string = "postgresql://prod-server:5432/myapp"
27
- end
28
- end
29
-
30
- class DevelopmentDB < Taski::Task
31
- def run
32
- puts "Connecting to development database..."
33
- sleep(0.3)
34
- puts "Development DB connected"
35
- @connection_string = "postgresql://localhost:5432/myapp_dev"
36
- end
37
- end
38
- end
39
-
40
- # API section with multiple impl candidates
41
- class ApiSection < Taski::Section
42
- interfaces :base_url
43
-
44
- def impl
45
- if ENV["USE_STAGING_API"] == "1"
46
- StagingApi
47
- else
48
- ProductionApi
49
- end
50
- end
51
-
52
- class ProductionApi < Taski::Task
53
- def run
54
- puts "Initializing production API..."
55
- sleep(0.4)
56
- @base_url = "https://api.example.com"
57
- end
58
- end
59
-
60
- class StagingApi < Taski::Task
61
- def run
62
- puts "Initializing staging API..."
63
- sleep(0.2)
64
- @base_url = "https://staging.api.example.com"
65
- end
66
- end
67
- end
68
-
69
- # Task with stdout output
70
- class FetchUserData < Taski::Task
71
- exports :users
72
-
73
- def run
74
- puts "Fetching users from database..."
75
- sleep(0.3)
76
- puts "Found 100 users"
77
- sleep(0.2)
78
- puts "Processing user records..."
79
- sleep(0.3)
80
- puts "User data ready"
81
- @users = ["Alice", "Bob", "Charlie"]
82
- end
83
- end
84
-
85
- class FetchProductData < Taski::Task
86
- exports :products
87
-
88
- def run
89
- puts "Loading product catalog..."
90
- sleep(0.4)
91
- puts "Fetched 50 products"
92
- sleep(0.2)
93
- puts "Indexing products..."
94
- sleep(0.3)
95
- @products = ["Widget", "Gadget", "Thing"]
96
- end
97
- end
98
-
99
- class BuildReport < Taski::Task
100
- exports :report
101
-
102
- def run
103
- db = DatabaseSection.connection_string
104
- api = ApiSection.base_url
105
- users = FetchUserData.users
106
- products = FetchProductData.products
107
-
108
- puts "Building report..."
109
- sleep(0.2)
110
- puts "Aggregating data from #{users.size} users..."
111
- sleep(0.3)
112
- puts "Processing #{products.size} products..."
113
- sleep(0.2)
114
- puts "Report generated successfully"
115
-
116
- @report = {
117
- database: db,
118
- api: api,
119
- user_count: users.size,
120
- product_count: products.size
121
- }
122
- end
123
- end
124
-
125
- class SendNotification < Taski::Task
126
- exports :notification_sent
127
-
128
- def run
129
- BuildReport.report
130
- puts "Sending notification..."
131
- sleep(0.2)
132
- puts "Email sent to admin@example.com"
133
- @notification_sent = true
134
- end
135
- end
136
-
137
- class Application < Taski::Task
138
- exports :status
139
-
140
- def run
141
- notification = SendNotification.notification_sent
142
- puts "Application startup complete"
143
- @status = notification ? "success" : "failed"
144
- end
145
- end
146
-
147
- # Show tree structure before execution
148
- puts "Task Tree Structure:"
149
- puts "=" * 60
150
- puts Application.tree
151
- puts "=" * 60
152
- puts
153
-
154
- # Reset for execution
155
- Application.reset!
156
-
157
- # Execute with tree progress display (start/stop handled automatically by Executor)
158
- result = Application.status
159
-
160
- puts "\n"
161
- puts "=" * 60
162
- puts "Execution completed!"
163
- puts "Status: #{result}"
164
- puts "Report: #{BuildReport.report.inspect}"