class GradesFirst::TaskToggleCommand
Implementation of a Thor command for toggling whether or not a task is complete.
Public Class Methods
description()
click to toggle source
Description of the “gf task toggle” Thor command that will be used in the commandline help.
# File lib/gradesfirst/task_toggle_command.rb, line 10 def self.description 'Toggle completion status of a PivotalTracker story task.' end
Public Instance Methods
execute(position)
click to toggle source
Performs the gf task toggle POSITION Thor command.
# File lib/gradesfirst/task_toggle_command.rb, line 15 def execute(position) @story = current_story if @story task = get_task_by_position(@story, position) if task @success = task_toggle(@story, task) else @task_position_invalid = true end end end
response()
click to toggle source
Generates the command line output response. The output of the task toggle command is a completion status message which may be followed by the new list of tasks if the task was moved successfully.
# File lib/gradesfirst/task_toggle_command.rb, line 30 def response if @task_position_invalid position_invalid_message else task_action_response(@story, @success) end end
Private Instance Methods
position_invalid_message()
click to toggle source
# File lib/gradesfirst/task_toggle_command.rb, line 40 def position_invalid_message 'Task position given does not exist.' end
story_error_message()
click to toggle source
# File lib/gradesfirst/task_toggle_command.rb, line 44 def story_error_message 'Tasks cannot be toggled for this branch.' end
task_error_message()
click to toggle source
# File lib/gradesfirst/task_toggle_command.rb, line 48 def task_error_message 'Toggling of the task completion status failed.' end
task_success_message()
click to toggle source
# File lib/gradesfirst/task_toggle_command.rb, line 52 def task_success_message 'Task completion status was successfully toggled.' end
task_toggle(story, task)
click to toggle source
# File lib/gradesfirst/task_toggle_command.rb, line 56 def task_toggle(story, task) PivotalTracker. projects[story['project_id']]. stories[story['id']]. tasks[task['id']]. put(complete: !task['complete']) end