class PTT::Client
Constants
- STORY_FIELDS
Public Class Methods
get_api_token(email, password)
click to toggle source
# File lib/ptt/client.rb, line 10 def self.get_api_token(email, password) PivotalAPI::Me.retrieve(email, password) rescue RestClient::Unauthorized raise PTT::InputError.new("Bad email/password combination.") end
new(token)
click to toggle source
# File lib/ptt/client.rb, line 16 def initialize(token) @client = TrackerApi::Client.new(token: token) @project = nil end
Public Instance Methods
add_label(project, task, label)
click to toggle source
# File lib/ptt/client.rb, line 134 def add_label(project, task, label) task = get_story(project, task.id) task.add_label(label) task.save end
assign_task(project, task, owner)
click to toggle source
# File lib/ptt/client.rb, line 129 def assign_task(project, task, owner) task = get_story(project, task.id) task.add_owner(owner) end
comment_task(project, task, comment)
click to toggle source
# File lib/ptt/client.rb, line 140 def comment_task(project, task, comment) task = get_story(project, task.id) task.create_comment(text: comment) end
create_task(project, name, owner_ids, task_type)
click to toggle source
# File lib/ptt/client.rb, line 145 def create_task(project, name, owner_ids, task_type) project.create_story(:name => name, :story_type => task_type, owner_ids: owner_ids) end
create_task_with_description(project, name, owner, task_type, description)
click to toggle source
# File lib/ptt/client.rb, line 149 def create_task_with_description(project, name, owner, task_type, description) project.create_story(:name => name, :story_type => task_type, :description => description) end
estimate_task(project, task, points)
click to toggle source
# File lib/ptt/client.rb, line 123 def estimate_task(project, task, points) task = get_story(project, task.id) task.estimate = points task.save end
find_member(project, query)
click to toggle source
# File lib/ptt/client.rb, line 106 def find_member(project, query) memberships = project.memberships.detect do |m| m.person.name.downcase.start_with?(query.downcase) || m.person.initials.downcase == query.downcase end end
get_activities(project, limit)
click to toggle source
# File lib/ptt/client.rb, line 42 def get_activities(project, limit) project.activity end
get_all_stories(project, user_name)
click to toggle source
# File lib/ptt/client.rb, line 96 def get_all_stories(project, user_name) project.stories limit: 50, fields: STORY_FIELDS end
get_current_iteration(project)
click to toggle source
# File lib/ptt/client.rb, line 38 def get_current_iteration(project) PivotalTracker::Iteration.current(project) end
get_member(project, query)
click to toggle source
# File lib/ptt/client.rb, line 101 def get_member(project, query) member = project.memberships.select{ |m| m.person.name.downcase.start_with?(query.downcase) || m.person.initials.downcase == query.downcase } member.empty? ? nil : member.first end
get_members(project)
click to toggle source
# File lib/ptt/client.rb, line 112 def get_members(project) project.memberships fields: ':default,person' end
get_membership(project, email)
click to toggle source
# File lib/ptt/client.rb, line 30 def get_membership(project, email) PivotalTracker::Membership.all(project).select{ |m| m.email == email }.first end
get_my_info()
click to toggle source
# File lib/ptt/client.rb, line 34 def get_my_info @client.me end
get_my_open_tasks(project, user_name)
click to toggle source
# File lib/ptt/client.rb, line 63 def get_my_open_tasks(project, user_name) project.stories filter: "owner:#{user_name}", fields: STORY_FIELDS end
get_my_tasks_to_accept(project, user_name)
click to toggle source
# File lib/ptt/client.rb, line 84 def get_my_tasks_to_accept(project, user_name) project.stories filter: "owner:#{user_name} -state:accepted", limit: 50, fields: STORY_FIELDS end
get_my_tasks_to_deliver(project, user_name)
click to toggle source
# File lib/ptt/client.rb, line 80 def get_my_tasks_to_deliver(project, user_name) project.stories filter: "owner:#{user_name} -state:delivered,accepted,rejected", limit: 50, fields: STORY_FIELDS end
get_my_tasks_to_estimate(project, user_name)
click to toggle source
# File lib/ptt/client.rb, line 67 def get_my_tasks_to_estimate(project, user_name) project.stories( filter: "owner:#{user_name} type:feature estimate:-1", fields: STORY_FIELDS) end
get_my_tasks_to_finish(project, user_name)
click to toggle source
# File lib/ptt/client.rb, line 76 def get_my_tasks_to_finish(project, user_name) project.stories filter: "owner:#{user_name} -state:finished,delivered,accepted,rejected", limit: 50, fields: STORY_FIELDS end
get_my_tasks_to_reject(project, user_name)
click to toggle source
# File lib/ptt/client.rb, line 88 def get_my_tasks_to_reject(project, user_name) project.stories filter: "owner:#{user_name} -state:rejected", limit: 50, fields: STORY_FIELDS end
get_my_tasks_to_start(project, user_name)
click to toggle source
# File lib/ptt/client.rb, line 71 def get_my_tasks_to_start(project, user_name) tasks = project.stories filter: "owner:#{user_name} state:unscheduled,rejected,unstarted", limit: 50, fields: STORY_FIELDS tasks.reject{ |t| (t.story_type == 'feature') && (t.estimate == -1) } end
get_my_work(project, user_name)
click to toggle source
# File lib/ptt/client.rb, line 50 def get_my_work(project, user_name) project.stories(filter: "owner:#{user_name} -state:accepted", limit: 50, fields: STORY_FIELDS) end
get_project(project_id)
click to toggle source
# File lib/ptt/client.rb, line 21 def get_project(project_id) project = @client.project(project_id) project end
get_projects()
click to toggle source
# File lib/ptt/client.rb, line 26 def get_projects @client.projects end
get_task_by_id(project, id)
click to toggle source
# File lib/ptt/client.rb, line 58 def get_task_by_id(project, id) project.story(id, fields: STORY_FIELDS) end
Also aliased as: get_story
get_tasks_to_assign(project)
click to toggle source
# File lib/ptt/client.rb, line 92 def get_tasks_to_assign(project) project.stories filter: "-state:accepted", limit: 50 end
get_work(project)
click to toggle source
# File lib/ptt/client.rb, line 46 def get_work(project) project.stories(filter: 'state:unscheduled,unstarted,started', fields: STORY_FIELDS ) end
mark_task_as(project, task, state)
click to toggle source
# File lib/ptt/client.rb, line 117 def mark_task_as(project, task, state) task = get_story(project, task.id) task.current_state = state task.save end
search_for_story(project, query)
click to toggle source
# File lib/ptt/client.rb, line 54 def search_for_story(project, query) project.stories(filter: query.to_s ,fields: STORY_FIELDS) end