Class: Ace::Git::Worktree::Molecules::TaskStatusUpdater
- Inherits:
-
Object
- Object
- Ace::Git::Worktree::Molecules::TaskStatusUpdater
- Defined in:
- lib/ace/git/worktree/molecules/task_status_updater.rb
Overview
Task status updater molecule
Updates task status using ace-task Ruby API or CLI commands. Provides methods for marking tasks as in-progress, done, etc. All methods return a result hash with :success and :message keys.
Constant Summary collapse
- DEFAULT_TIMEOUT =
Default timeout for ace-task commands
10
Instance Method Summary collapse
-
#add_pr_metadata(task_ref, pr_data) ⇒ Boolean
Add PR metadata to task.
-
#add_started_at_timestamp(task_ref) ⇒ Boolean
Add started_at timestamp to task.
-
#add_worktree_metadata(task_ref, worktree_metadata) ⇒ Boolean
Add worktree metadata to task.
-
#get_status(task_ref) ⇒ String?
Get current task status.
-
#initialize(timeout: DEFAULT_TIMEOUT) ⇒ TaskStatusUpdater
constructor
Initialize a new TaskStatusUpdater.
-
#mark_blocked(task_ref) ⇒ Hash
Mark task as blocked.
-
#mark_done(task_ref) ⇒ Hash
Mark task as done.
-
#mark_in_progress(task_ref) ⇒ Hash
Mark task as in-progress.
-
#remove_worktree_metadata(task_ref) ⇒ Boolean
Remove worktree metadata from task.
-
#update_command_available? ⇒ Boolean
Check if ace-task update command is available.
-
#update_estimate(task_ref, estimate) ⇒ Boolean
Update task estimate.
-
#update_priority(task_ref, priority) ⇒ Boolean
Update task priority.
-
#update_status(task_ref, status) ⇒ Hash
Update task to custom status.
Constructor Details
#initialize(timeout: DEFAULT_TIMEOUT) ⇒ TaskStatusUpdater
Initialize a new TaskStatusUpdater
36 37 38 39 |
# File 'lib/ace/git/worktree/molecules/task_status_updater.rb', line 36 def initialize(timeout: DEFAULT_TIMEOUT) @timeout = timeout @project_root = ENV["PROJECT_ROOT_PATH"] || Dir.pwd end |
Instance Method Details
#add_pr_metadata(task_ref, pr_data) ⇒ Boolean
Add PR metadata to task
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
# File 'lib/ace/git/worktree/molecules/task_status_updater.rb', line 152 def (task_ref, pr_data) return false unless pr_data.is_a?(Hash) return false unless pr_data[:number] && pr_data[:url] normalized_ref = normalize_task_reference(task_ref) return false unless normalized_ref # Try Ruby API first (preferred in mono-repo) if use_ruby_api? return (task_ref, pr_data) end # Fallback to CLI for standalone installations (task_ref, pr_data) end |
#add_started_at_timestamp(task_ref) ⇒ Boolean
Add started_at timestamp to task
172 173 174 175 176 177 178 179 180 181 182 183 184 185 |
# File 'lib/ace/git/worktree/molecules/task_status_updater.rb', line 172 def (task_ref) started_at = Time.now normalized_ref = normalize_task_reference(task_ref) return false unless normalized_ref # Try Ruby API first (preferred in mono-repo) if use_ruby_api? return add_started_at_via_api(task_ref, started_at) end # Fallback to CLI for standalone installations add_started_at_via_cli(task_ref, started_at) end |
#add_worktree_metadata(task_ref, worktree_metadata) ⇒ Boolean
Add worktree metadata to task
135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/ace/git/worktree/molecules/task_status_updater.rb', line 135 def (task_ref, ) return false unless .is_a?(Models::WorktreeMetadata) # Try Ruby API first (preferred in mono-repo) if use_ruby_api? return (task_ref, ) end # Fallback to CLI for standalone installations (task_ref, ) end |
#get_status(task_ref) ⇒ String?
Get current task status
202 203 204 205 206 207 208 209 210 |
# File 'lib/ace/git/worktree/molecules/task_status_updater.rb', line 202 def get_status(task_ref) normalized_ref = normalize_task_reference(task_ref) return nil unless normalized_ref # Fetch task metadata fetcher = TaskFetcher.new task = fetcher.fetch(normalized_ref) task ? task[:status] : nil end |
#mark_blocked(task_ref) ⇒ Hash
Mark task as blocked
61 62 63 |
# File 'lib/ace/git/worktree/molecules/task_status_updater.rb', line 61 def mark_blocked(task_ref) update_status(task_ref, "blocked") end |
#mark_done(task_ref) ⇒ Hash
Mark task as done
53 54 55 |
# File 'lib/ace/git/worktree/molecules/task_status_updater.rb', line 53 def mark_done(task_ref) update_status(task_ref, "done") end |
#mark_in_progress(task_ref) ⇒ Hash
Mark task as in-progress
45 46 47 |
# File 'lib/ace/git/worktree/molecules/task_status_updater.rb', line 45 def mark_in_progress(task_ref) update_status(task_ref, "in-progress") end |
#remove_worktree_metadata(task_ref) ⇒ Boolean
Remove worktree metadata from task
191 192 193 194 195 196 |
# File 'lib/ace/git/worktree/molecules/task_status_updater.rb', line 191 def (task_ref) normalized_ref = normalize_task_reference(task_ref) return false unless normalized_ref false end |
#update_command_available? ⇒ Boolean
Check if ace-task update command is available
215 216 217 218 |
# File 'lib/ace/git/worktree/molecules/task_status_updater.rb', line 215 def update_command_available? result = execute_ace_task_command("update", "--help", timeout: 5) result[:success] end |
#update_estimate(task_ref, estimate) ⇒ Boolean
Update task estimate
116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/ace/git/worktree/molecules/task_status_updater.rb', line 116 def update_estimate(task_ref, estimate) return false if estimate.nil? || estimate.empty? normalized_ref = normalize_task_reference(task_ref) return false unless normalized_ref if use_ruby_api? return update_fields_via_api(normalized_ref, {"estimate" => estimate}) end result = execute_ace_task_command("update", normalized_ref, "--set", "estimate=#{estimate}") result[:success] end |
#update_priority(task_ref, priority) ⇒ Boolean
Update task priority
97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/ace/git/worktree/molecules/task_status_updater.rb', line 97 def update_priority(task_ref, priority) return false unless %w[high medium low].include?(priority.to_s) normalized_ref = normalize_task_reference(task_ref) return false unless normalized_ref if use_ruby_api? return update_fields_via_api(normalized_ref, {"priority" => priority}) end result = execute_ace_task_command("update", normalized_ref, "--set", "priority=#{priority}") result[:success] end |
#update_status(task_ref, status) ⇒ Hash
Update task to custom status
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/ace/git/worktree/molecules/task_status_updater.rb', line 70 def update_status(task_ref, status) return {success: false, message: "Task reference is required"} if task_ref.nil? || task_ref.empty? return {success: false, message: "Status is required"} if status.nil? || status.empty? puts "DEBUG: TaskStatusUpdater.update_status called with task_ref=#{task_ref}, status=#{status}" if ENV["DEBUG"] puts "DEBUG: use_ruby_api? = #{use_ruby_api?}" if ENV["DEBUG"] # Try Ruby API first (preferred in mono-repo) if use_ruby_api? puts "DEBUG: Using Ruby API for status update" if ENV["DEBUG"] result = update_status_via_api(task_ref, status) puts "DEBUG: Ruby API result: #{result}" if ENV["DEBUG"] return result end # Fallback to CLI for standalone installations puts "DEBUG: Using CLI for status update" if ENV["DEBUG"] result = update_status_via_cli(task_ref, status) puts "DEBUG: CLI result: #{result}" if ENV["DEBUG"] result end |