class GradesFirst::TaskMoveCommand
Implementation of a Thor command for moving tasks on a PivotalTracker
story from one priority position to another in the list.
Public Class Methods
description()
click to toggle source
Description of the “gf task move” Thor command that will be sued in the commandline help.
# File lib/gradesfirst/task_move_command.rb, line 10 def self.description 'Move a task to a new position in the list for a PivotalTracker story.' end
Public Instance Methods
execute(from, to)
click to toggle source
Performs the gf task move Thor command.
# File lib/gradesfirst/task_move_command.rb, line 15 def execute(from, to) @story = current_story if @story task_id = get_task_id_by_position(@story, from) if task_id @success = task_move(@story, task_id, to) else @task_position_invalid = true end end end
response()
click to toggle source
Generates the command line output response. The output of the task move 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_move_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_move_command.rb, line 40 def position_invalid_message 'Task "from" position given does not exist.' end
story_error_message()
click to toggle source
# File lib/gradesfirst/task_move_command.rb, line 44 def story_error_message 'Tasks cannnot be moved for this branch.' end
task_error_message()
click to toggle source
# File lib/gradesfirst/task_move_command.rb, line 48 def task_error_message 'Moving the task failed.' end
task_move(story, task_id, to)
click to toggle source
# File lib/gradesfirst/task_move_command.rb, line 52 def task_move(story, task_id, to) PivotalTracker. projects[story['project_id']]. stories[story['id']]. tasks[task_id]. put(position: to.to_i) end
task_success_message()
click to toggle source
# File lib/gradesfirst/task_move_command.rb, line 60 def task_success_message 'Task was successfully moved.' end