class GradesFirst::TaskDeleteCommand

Implementation of a Thor command for deleting tasks from PivotalTracker stories.

Public Class Methods

description() click to toggle source

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

# File lib/gradesfirst/task_delete_command.rb, line 10
def self.description
  'Delete a task from a PivotalTracker story.'
end

Public Instance Methods

execute(position) click to toggle source

Performs the gf task delete POSITION Thor command.

# File lib/gradesfirst/task_delete_command.rb, line 15
def execute(position)
  @story = current_story
  if @story
    task_id = get_task_id_by_position(@story, position)
    if task_id
      @success = task_delete(@story, task_id)
    else
      @task_position_invalid = true
    end
  end
end
response() click to toggle source

Generates the command line output response. The output of the task delete command is a completion status message which may be followed by the new list of tasks if the task was deleted successfully.

# File lib/gradesfirst/task_delete_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_delete_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_delete_command.rb, line 44
def story_error_message
  'Tasks cannot be deleted for this branch.'
end
task_delete(story, task_id) click to toggle source
# File lib/gradesfirst/task_delete_command.rb, line 48
def task_delete(story, task_id)
  PivotalTracker.
    projects[story['project_id']].
    stories[story['id']].
    tasks[task_id].
    delete
end
task_error_message() click to toggle source
# File lib/gradesfirst/task_delete_command.rb, line 56
def task_error_message
  'Deletion of the task failed.'
end
task_success_message() click to toggle source
# File lib/gradesfirst/task_delete_command.rb, line 60
def task_success_message
  'Task was successfully deleted.'
end