taski 0.2.2 → 0.2.3

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: 28f2e52366511da4606df64a169c804712fcf4398b55a7b7d6430a1367cc183d
4
- data.tar.gz: 97cc63c767ceaf7dda2fbb4345876c47d1fb1bf7e0395c8a2a0369bc8585e817
3
+ metadata.gz: da68d3dc067cdf14dd29a438cbf88cc7b00769000682417dc3395eb63f1a1659
4
+ data.tar.gz: a5ec661eeea77a73f77b07cbc09dfc4aef88fce2e856bac0366a5e32782356cc
5
5
  SHA512:
6
- metadata.gz: 4558c7e5ab3ae48301da573a0d2dffa935ecf2bdf7f04ccce1b92add5ea45b3aea1b562dcce0c6356d28b7eacd58fcdca030a9a2748fbafdda9d9046b5a09213
7
- data.tar.gz: f440abca3014be0bffdd34cb8440f197b55403fc938660a8eb311e1bb6c64127bf9d033335d7e52f71cefec534ae4b6e41e2b83164d76b893d3a3c8f692bc221
6
+ metadata.gz: 68b3c5ddaf63a71067fea5f3c6fdc47c80e6a020f0e7bd417f8cc03e8f595aa4a3f0b16826bf3d8a65935959ee7a243074c51db4bb766c296d25c73817fe90a8
7
+ data.tar.gz: ed2a3f80b1a5987c9a2ce8d410c6594c4edd35483a1be9507de0565582facba12e238f2862ae5964af27180431c21b3b80d00887aab8525ee89af2bfb91a507a
data/README.md CHANGED
@@ -118,6 +118,81 @@ EnvironmentConfig.build
118
118
  - **Circular Dependency Detection**: Clear error messages with detailed paths
119
119
  - **Granular Execution**: Build individual tasks or complete graphs
120
120
  - **Memory Management**: Built-in reset mechanisms
121
+ - **Progress Display**: Visual feedback with spinners and output capture
122
+ - **Dependency Tree Visualization**: Visual representation of task relationships
123
+
124
+ ### Dependency Tree Visualization
125
+
126
+ Visualize task dependencies with the `tree` method:
127
+
128
+ ```ruby
129
+ class Database < Taski::Task
130
+ exports :connection
131
+ def build; @connection = "db-conn"; end
132
+ end
133
+
134
+ class Cache < Taski::Task
135
+ exports :redis_url
136
+ def build; @redis_url = "redis://localhost"; end
137
+ end
138
+
139
+ class Config < Taski::Task
140
+ exports :settings
141
+ def build
142
+ @settings = {
143
+ database: Database.connection,
144
+ cache: Cache.redis_url
145
+ }
146
+ end
147
+ end
148
+
149
+ class WebServer < Taski::Task
150
+ def build
151
+ puts "Starting with #{Config.settings}"
152
+ end
153
+ end
154
+
155
+ puts WebServer.tree
156
+ # => WebServer
157
+ # => └── Config
158
+ # => ├── Database
159
+ # => └── Cache
160
+ ```
161
+
162
+ ### Progress Display
163
+
164
+ Taski provides visual feedback during task execution with animated spinners and real-time output capture:
165
+
166
+ ```ruby
167
+ class LongRunningTask < Taski::Task
168
+ def build
169
+ puts "Starting process..."
170
+ sleep(1.0)
171
+ puts "Processing data..."
172
+ puts "Almost done..."
173
+ sleep(0.5)
174
+ puts "Completed!"
175
+ end
176
+ end
177
+
178
+ LongRunningTask.build
179
+ # During execution shows:
180
+ # ⠧ LongRunningTask
181
+ # Starting process...
182
+ # Processing data...
183
+ # Almost done...
184
+ # Completed!
185
+ #
186
+ # After completion shows:
187
+ # ✅ LongRunningTask (1500ms)
188
+ ```
189
+
190
+ **Progress Display Features:**
191
+ - **Spinner Animation**: Dots-style spinner during task execution
192
+ - **Output Capture**: Real-time display of task output (last 5 lines)
193
+ - **Status Indicators**: ✅ for success, ❌ for failure
194
+ - **Execution Time**: Shows task duration after completion
195
+ - **TTY Detection**: Clean output when redirected to files
121
196
 
122
197
  ### Granular Task Execution
123
198
 
@@ -190,7 +265,7 @@ class FileTask < Taski::Task
190
265
  def clean
191
266
  # ❌ Bad: Raises error if file doesn't exist
192
267
  # File.delete(@output_file)
193
-
268
+
194
269
  # ✅ Good: Check before delete
195
270
  File.delete(@output_file) if File.exist?(@output_file)
196
271
  end
@@ -207,7 +282,7 @@ rescue Taski::CircularDependencyError => e
207
282
  end
208
283
  # => Circular dependency: Circular dependency detected!
209
284
  # => Cycle: TaskA → TaskB → TaskA
210
- # =>
285
+ # =>
211
286
  # => The dependency chain is:
212
287
  # => 1. TaskA is trying to build → TaskB
213
288
  # => 2. TaskB is trying to build → TaskA
@@ -247,4 +322,4 @@ MIT License
247
322
 
248
323
  ---
249
324
 
250
- **Taski** - Build dependency graphs with elegant Ruby code. 🚀
325
+ **Taski** - Build dependency graphs with elegant Ruby code. 🚀
@@ -38,7 +38,7 @@ module Taski
38
38
  method_node = find_method_node(result.value, method_name, line_number)
39
39
 
40
40
  if method_node
41
- visitor = TaskDependencyVisitor.new
41
+ visitor = TaskDependencyVisitor.new(klass)
42
42
  visitor.visit(method_node)
43
43
  dependencies = visitor.dependencies
44
44
  end
@@ -96,9 +96,10 @@ module Taski
96
96
  class TaskDependencyVisitor < Prism::Visitor
97
97
  attr_reader :dependencies
98
98
 
99
- def initialize
99
+ def initialize(context_class = nil)
100
100
  @dependencies = []
101
101
  @constant_cache = {}
102
+ @context_class = context_class
102
103
  end
103
104
 
104
105
  def visit_constant_read_node(node)
@@ -135,14 +136,19 @@ module Taski
135
136
  return @dependencies << cached_result if cached_result # Cached positive result
136
137
 
137
138
  begin
139
+ resolved_class = nil
140
+
141
+ # 1. Try absolute reference first (existing logic)
138
142
  if Object.const_defined?(const_name)
139
- klass = Object.const_get(const_name)
140
- if klass.is_a?(Class) && klass < Taski::Task
141
- @constant_cache[const_name] = klass
142
- @dependencies << klass
143
- else
144
- @constant_cache[const_name] = false
145
- end
143
+ resolved_class = Object.const_get(const_name)
144
+ # 2. Try relative reference within namespace context
145
+ elsif @context_class
146
+ resolved_class = resolve_relative_constant(const_name)
147
+ end
148
+
149
+ if resolved_class&.is_a?(Class) && resolved_class < Taski::Task
150
+ @constant_cache[const_name] = resolved_class
151
+ @dependencies << resolved_class
146
152
  else
147
153
  @constant_cache[const_name] = false
148
154
  end
@@ -151,6 +157,32 @@ module Taski
151
157
  end
152
158
  end
153
159
 
160
+ def resolve_relative_constant(const_name)
161
+ return nil unless @context_class
162
+
163
+ # Get the namespace from the context class
164
+ namespace = get_namespace_from_class(@context_class)
165
+ return nil unless namespace
166
+
167
+ # Try to resolve the constant within the namespace
168
+ full_const_name = "#{namespace}::#{const_name}"
169
+ Object.const_get(full_const_name) if Object.const_defined?(full_const_name)
170
+ rescue NameError, ArgumentError
171
+ nil
172
+ end
173
+
174
+ def get_namespace_from_class(klass)
175
+ # Extract namespace from class name (e.g., "A::AB" -> "A")
176
+ class_name = klass.name
177
+ return nil unless class_name&.include?("::")
178
+
179
+ # Split by "::" and take all but the last part
180
+ parts = class_name.split("::")
181
+ return nil if parts.length <= 1 # No namespace
182
+
183
+ parts[0..-2].join("::")
184
+ end
185
+
154
186
  def extract_constant_path(node)
155
187
  case node
156
188
  when Prism::ConstantReadNode
data/lib/taski/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Taski
4
- VERSION = "0.2.2"
4
+ VERSION = "0.2.3"
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: taski
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - ahogappa
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-06-27 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: prism
@@ -78,7 +78,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
78
78
  - !ruby/object:Gem::Version
79
79
  version: '0'
80
80
  requirements: []
81
- rubygems_version: 3.6.2
81
+ rubygems_version: 3.6.7
82
82
  specification_version: 4
83
83
  summary: A simple yet powerful Ruby task runner with static dependency resolution
84
84
  (in development).