Class: TaskMapper::Provider::Trac::Ticket
- Inherits:
-
Base::Ticket
- Object
- Base::Ticket
- TaskMapper::Provider::Trac::Ticket
- Defined in:
- lib/provider/ticket.rb
Overview
Ticket class for taskmapper-yoursystem
Class Method Summary collapse
- .create(*options) ⇒ Object
- .find(project_id, *options) ⇒ Object
- .find_all(project_id, tickets) ⇒ Object
- .find_by_id(id, project_id) ⇒ Object
- .trac ⇒ Object
Instance Method Summary collapse
- #comment(*options) ⇒ Object
- #comment! ⇒ Object
- #comments(*options) ⇒ Object
- #created_at ⇒ Object
-
#initialize(*object) ⇒ Ticket
constructor
declare needed overloaded methods here.
- #updated_at ⇒ Object
Constructor Details
#initialize(*object) ⇒ Ticket
declare needed overloaded methods here
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/provider/ticket.rb', line 9 def initialize(*object) if object.first args = object object = args.shift project_id = args.shift unless object.is_a? Hash @system_data = {:client => object} hash = {:id => object.id, :severity => object.severity, :milestone => object.milestone, :status => object.status, :type => object.type, :priority => object.priority, :version => object.version, :reporter => object.reporter, :owner => object.owner, :cc => object.cc, :summary => object.summary, :assignee => object.owner, :requestor => object.reporter, :title => object.summary, :project_id => project_id, :description => object.description, :keywords => object.keywords, :created_at => object.created_at, :updated_at => object.updated_at} else hash = object end super(hash) end end |
Class Method Details
.create(*options) ⇒ Object
74 75 76 77 78 79 80 81 |
# File 'lib/provider/ticket.rb', line 74 def self.create(*) mandatory = .shift attributes = {} attributes ||= .shift self.find_by_id trac[:trac].tickets.create(mandatory[:summary], mandatory[:description], attributes) rescue self end |
.find(project_id, *options) ⇒ Object
57 58 59 60 61 62 63 64 65 66 |
# File 'lib/provider/ticket.rb', line 57 def self.find(project_id, *) mode = [0].first if [0].empty? self.find_all(project_id, trac[:trac].tickets.list) elsif mode.is_a? Array self.find_all(project_id, mode) elsif mode.is_a? Hash self.find_all(project_id, trac[:trac].tickets.query(mode)) end end |
.find_all(project_id, tickets) ⇒ Object
68 69 70 71 72 |
# File 'lib/provider/ticket.rb', line 68 def self.find_all(project_id, tickets) tickets.collect do |ticket_id| self.find_by_id(ticket_id, project_id) end end |
.find_by_id(id, project_id) ⇒ Object
50 51 52 53 54 55 |
# File 'lib/provider/ticket.rb', line 50 def self.find_by_id(id, project_id) tries ||= 3 self.new trac[:trac].tickets.get(id), project_id rescue ::Trac::TracException retry unless (tries-=1).zero? end |
.trac ⇒ Object
83 84 85 |
# File 'lib/provider/ticket.rb', line 83 def self.trac TaskMapper::Provider::Trac.api end |
Instance Method Details
#comment(*options) ⇒ Object
91 92 93 94 95 96 97 98 99 |
# File 'lib/provider/ticket.rb', line 91 def comment(*) if .empty? TaskMapper::Provider::Trac::Comment.new elsif .first.is_a? Fixnum Comment.find_by_id(self.project_id, self.id, .first) elsif .first.is_a? Hash Comment.find_by_attributes(self.project_id, self.id, .first).first end end |
#comment! ⇒ Object
101 102 103 104 |
# File 'lib/provider/ticket.rb', line 101 def comment! warn "Trac doesn't support creation of comments" [] end |
#comments(*options) ⇒ Object
87 88 89 |
# File 'lib/provider/ticket.rb', line 87 def comments(*) Comment.find(self.project_id, self.id, ) end |
#created_at ⇒ Object
42 43 44 |
# File 'lib/provider/ticket.rb', line 42 def created_at normalize_datetime(self[:created_at]) end |
#updated_at ⇒ Object
46 47 48 |
# File 'lib/provider/ticket.rb', line 46 def updated_at normalize_datetime(self[:updated_at]) end |