class GradesFirst::TaskCommand
Private Instance Methods
get_task_by_position(story, position)
click to toggle source
# File lib/gradesfirst/task_command.rb, line 12 def get_task_by_position(story, position) get_tasks(story).find { |t| t['position'] == position.to_i } end
get_task_id_by_position(story, position)
click to toggle source
# File lib/gradesfirst/task_command.rb, line 7 def get_task_id_by_position(story, position) task = get_task_by_position(story, position) task['id'] if task end
get_tasks(story)
click to toggle source
# File lib/gradesfirst/task_command.rb, line 16 def get_tasks(story) PivotalTracker. projects[story['project_id']]. stories[story['id']]. tasks. get end
position(task)
click to toggle source
# File lib/gradesfirst/task_command.rb, line 24 def position(task) task['position'].to_s.rjust(2) end
story_line(story)
click to toggle source
# File lib/gradesfirst/task_command.rb, line 28 def story_line(story) "#{TAB}#{story['name']} (#{story['url']})\n\n" end
task_action_response(story, success)
click to toggle source
Generates the commandline output response for actions taken on tasks like add and delete.
# File lib/gradesfirst/task_command.rb, line 34 def task_action_response(story, success) if story.nil? story_error_message elsif !success task_error_message else tasks = get_tasks(story) [ TAB + task_success_message, task_list_response(story, tasks) ].join("\n\n") end end
task_list_response(story, tasks)
click to toggle source
# File lib/gradesfirst/task_command.rb, line 48 def task_list_response(story, tasks) task_list = tasks.map do |t| "#{TAB}#{position(t)}. [#{t["complete"] ? 'X' : ' '}] #{t["description"]}" end story_line(story) + task_list.join("\n") + "\n" end