Class: GradesFirst::TaskMoveCommand

Inherits:
TaskCommand show all
Defined in:
lib/gradesfirst/task_move_command.rb

Overview

Implementation of a Thor command for moving tasks on a PivotalTracker story from one priority position to another in the list.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.descriptionObject

Description of the “gf task move” Thor command that will be sued in the commandline help.



10
11
12
# 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

Instance Method Details

#execute(from, to) ⇒ Object

Performs the gf task move Thor command.



15
16
17
18
19
20
21
22
23
24
25
# 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

#responseObject

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.



30
31
32
33
34
35
36
# 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