Class: TicketMaster::Provider::Pivotal::Ticket
- Inherits:
-
Base::Ticket
- Object
- Base::Ticket
- TicketMaster::Provider::Pivotal::Ticket
- Defined in:
- lib/provider/ticket.rb
Overview
Ticket class for ticketmaster-pivotal
-
id
-
status
-
priority
-
title => name
-
resolution
-
created_at
-
updated_at
-
description => text
-
assignee
-
requestor
-
project_id (prefix_options)
Constant Summary collapse
- API =
PivotalAPI::Story
- @@allowed_states =
['new', 'open', 'resolved', 'hold', 'invalid']
Instance Attribute Summary collapse
-
#prefix_options ⇒ Object
Returns the value of attribute prefix_options.
Class Method Summary collapse
- .create(options) ⇒ Object
- .filter(attributes = {}) ⇒ Object
- .find_by_attributes(project_id, attributes = {}) ⇒ Object
Instance Method Summary collapse
- #assignee ⇒ Object
-
#close(resolution = 'resolved') ⇒ Object
The closer.
- #comment!(*options) ⇒ Object
- #destroy(*options) ⇒ Object
- #priority ⇒ Object
- #project_id ⇒ Object
- #requestor ⇒ Object
- #resolution ⇒ Object
-
#save(*options) ⇒ Object
The saver.
- #status ⇒ Object
- #title ⇒ Object
- #title=(title) ⇒ Object
Instance Attribute Details
#prefix_options ⇒ Object
Returns the value of attribute prefix_options.
18 19 20 |
# File 'lib/provider/ticket.rb', line 18 def @prefix_options end |
Class Method Details
.create(options) ⇒ Object
99 100 101 102 103 104 105 |
# File 'lib/provider/ticket.rb', line 99 def create() super translate , {:title => :name, :requestor => :requested_by, :status => :current_state, :estimate => :priority, :assignee => :owned_by} end |
.filter(attributes = {}) ⇒ Object
91 92 93 94 95 96 97 |
# File 'lib/provider/ticket.rb', line 91 def filter(attributes = {}) filter = "" attributes.each_pair do |key, value| filter << "#{key}:#{value} " end filter.strip! end |
.find_by_attributes(project_id, attributes = {}) ⇒ Object
80 81 82 83 84 85 86 87 88 89 |
# File 'lib/provider/ticket.rb', line 80 def find_by_attributes(project_id, attributes = {}) date_to_search = attributes[:updated_at] || attributes[:created_at] tickets = [] unless date_to_search.nil? tickets = search_by_datefields(project_id, date_to_search) else tickets += API.find(:all, :params => {:project_id => project_id, :filter => filter(attributes)}).map { |xticket| self.new xticket } end tickets.flatten end |
Instance Method Details
#assignee ⇒ Object
63 64 65 |
# File 'lib/provider/ticket.rb', line 63 def assignee self.owned_by end |
#close(resolution = 'resolved') ⇒ Object
The closer
71 72 73 74 75 76 |
# File 'lib/provider/ticket.rb', line 71 def close(resolution = 'resolved') resolution = 'resolved' unless @@allowed_states.include?(resolution) ticket = PivotalAPI::Ticket.find(self.id, :params => {:project_id => self.[:project_id]}) ticket.state = resolution ticket.save end |
#comment!(*options) ⇒ Object
67 68 69 |
# File 'lib/provider/ticket.rb', line 67 def comment!(*) Comment.create(self.project_id, self.id, .first) end |
#destroy(*options) ⇒ Object
31 32 33 |
# File 'lib/provider/ticket.rb', line 31 def destroy(*) @system_data[:client].destroy.is_a?(Net::HTTPOK) end |
#priority ⇒ Object
55 56 57 |
# File 'lib/provider/ticket.rb', line 55 def priority self.estimate end |
#project_id ⇒ Object
35 36 37 |
# File 'lib/provider/ticket.rb', line 35 def project_id self.[:project_id] end |
#requestor ⇒ Object
39 40 41 |
# File 'lib/provider/ticket.rb', line 39 def requestor self.requested_by end |
#resolution ⇒ Object
59 60 61 |
# File 'lib/provider/ticket.rb', line 59 def resolution self.current_state end |
#save(*options) ⇒ Object
The saver
23 24 25 26 27 28 29 |
# File 'lib/provider/ticket.rb', line 23 def save(*) pt_ticket = @system_data[:client] self.keys.each do |key| pt_ticket.send(key + '=', self.send(key)) if self.send(key) != pt_ticket.send(key) end pt_ticket.save end |
#status ⇒ Object
51 52 53 |
# File 'lib/provider/ticket.rb', line 51 def status self.current_state end |
#title ⇒ Object
43 44 45 |
# File 'lib/provider/ticket.rb', line 43 def title self.name end |
#title=(title) ⇒ Object
47 48 49 |
# File 'lib/provider/ticket.rb', line 47 def title=(title) self.name=title end |