Class | Trac::Tickets |
In: |
lib/tickets.rb
|
Parent: | Object |
returns a list of attachments for the given ticket
# File lib/tickets.rb, line 113 113: def attachments ticket_id 114: @trac.query("ticket.listAttachments",ticket_id) 115: end
return the changelog as a list of tuples of the form (time,author, field,oldvalue,newvalue,permanent). While the other tuples elements are quite self-explanatory, the permanent flag is used to distinguish collateral changes that are not yet immutable (like attachments, currently).
# File lib/tickets.rb, line 103 103: def changelog ticket_id,w=0 104: @trac.query("ticket.changeLog",ticket_id,w) 105: end
deletes given attachment
# File lib/tickets.rb, line 128 128: def delete_attachment ticket_id,filename 129: @trac.query("ticket.deleteAttachment",ticket_id,filename) 130: end
fetch a ticket. Returns instance of Trac::Ticket
# File lib/tickets.rb, line 73 73: def get id 74: Ticket.load @trac.query("ticket.get",id) 75: end
returns all tickets (not just the ids) in a hash warning: to avoid heavy traffic load the results are cached and will only be updated after 5 minutes. use
get_all :cached_results => false
to avoid this. other options:
:include_closed - see Tickets#list for a description
# File lib/tickets.rb, line 55 55: def get_all options={ } 56: include_closed = options[:include_closed] || true 57: cached_results = options[:cached_results] || true 58: if(cached_results == true && 59: @cache_last_update && 60: @cache_last_update > Time.now - 300) 61: return @cache 62: end 63: tickets = { } 64: list(:include_closed => include_closed).each do |ticket| 65: tickets[ticket] = get ticket 66: end 67: @cache = tickets 68: @cache_last_update = Time.now 69: return tickets 70: end
returns the content of an attachment
# File lib/tickets.rb, line 118 118: def get_attachment ticket_id,filename 119: @trac.query("ticket.getAttachment",ticket_id,filename) 120: end
returns the settings in the same form as Tickets#settings, but refreshes them every time we call it.
# File lib/tickets.rb, line 150 150: def get_settings 151: @settings = { } 152: ['status','version','priority','resolution', 153: 'component','type','severity','milestone'].each do |setting| 154: @settings[setting.to_sym] = @trac.query("ticket.#{setting}.getAll") 155: end 156: return @settings 157: end
returns a list of all tickets (the ids), by performing two queries, one for closed tickets, one for opened. use
list :include_closed => false
to only get open tickets.
# File lib/tickets.rb, line 36 36: def list options={ } 37: include_closed = options[:include_closed] || true 38: tickets = @trac.query("ticket.query","status!=closed") 39: tickets += @trac.query("ticket.query","status=closed") if include_closed 40: return tickets 41: end
adds an attachment to a ticket
# File lib/tickets.rb, line 123 123: def put_attachment ticket_id,filename,description,data,replace=true 124: @trac.query("ticket.putAttachment",ticket_id,filename,description,data,replace) 125: end
returns all settings (possible values for status, version, priority, resolution, component, type, severity or milestone) as a hash in the form: { :status => ["assigned","closed",…], … } this method only gets the settings once per session. To update them please refer to Tickets#get_settings
# File lib/tickets.rb, line 143 143: def settings 144: @settings || get_settings 145: end
update ticket returning the ticket in the same orm as ticket.get
# File lib/tickets.rb, line 83 83: def update id,comment,attributes={ },notify=false 84: attr = {} 85: attributes.each_pair do |key, value| 86: unless(value.nil? || value.size == 0 || value.empty?) 87: attr[key] = value 88: end 89: end 90: @trac.query("ticket.update",id,comment,attr,notify) 91: end