taski 0.5.0 → 0.7.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.
@@ -1,78 +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 with Section
7
- # Run with: ruby examples/section_progress_demo.rb
8
-
9
- # Database 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.3)
25
- @connection_string = "postgresql://prod-server:5432/myapp"
26
- end
27
- end
28
-
29
- class DevelopmentDB < Taski::Task
30
- def run
31
- puts "Connecting to development database..."
32
- sleep(0.2)
33
- @connection_string = "postgresql://localhost:5432/myapp_dev"
34
- end
35
- end
36
- end
37
-
38
- # Simple task that uses the database
39
- class FetchData < Taski::Task
40
- exports :data
41
-
42
- def run
43
- db = DatabaseSection.connection_string
44
- puts "Fetching data from #{db}..."
45
- sleep(0.3)
46
- @data = ["item1", "item2", "item3"]
47
- end
48
- end
49
-
50
- # Main application task
51
- class Application < Taski::Task
52
- exports :result
53
-
54
- def run
55
- data = FetchData.data
56
- puts "Processing #{data.size} items..."
57
- sleep(0.2)
58
- @result = "Processed: #{data.join(", ")}"
59
- end
60
- end
61
-
62
- # Show tree structure before execution
63
- puts "Task Tree Structure:"
64
- puts "=" * 60
65
- puts Application.tree
66
- puts "=" * 60
67
- puts
68
-
69
- # Reset for execution
70
- Application.reset!
71
-
72
- # Execute
73
- result = Application.result
74
-
75
- puts "\n"
76
- puts "=" * 60
77
- puts "Execution completed!"
78
- puts "Result: #{result}"