Class Trac::Tickets
In: lib/tickets.rb
Parent: Object

Methods

Public Class methods

[Source]

    # File lib/tickets.rb, line 28
28:     def initialize trac
29:       @trac = trac
30:     end

Public Instance methods

returns the actions that can be performed on the ticket

[Source]

     # File lib/tickets.rb, line 133
133:     def actions ticket_id
134:       @trac.query("ticket.getAvailableActions",ticket_id)
135:     end

returns a list of attachments for the given ticket

[Source]

     # 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).

[Source]

     # File lib/tickets.rb, line 103
103:     def changelog ticket_id,w=0
104:       @trac.query("ticket.changeLog",ticket_id,w)
105:     end

returns a list of ids of tickets that have changed since `time‘

[Source]

     # File lib/tickets.rb, line 108
108:     def changes time
109:       @trac.query("ticket.getRecentChanges",time)
110:     end

create a new ticket returning the ticket id

[Source]

    # File lib/tickets.rb, line 78
78:     def create summary,description,attributes={ },notify=false
79:       @trac.query("ticket.create",summary,description,attributes,notify)
80:     end

delete ticket by id

[Source]

    # File lib/tickets.rb, line 94
94:     def delete id
95:       @trac.query("ticket.delete",id)
96:     end

deletes given attachment

[Source]

     # 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

[Source]

    # 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

[Source]

    # 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

[Source]

     # 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.

[Source]

     # 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.

[Source]

    # 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

like `list’, but only gets closed tickets

[Source]

    # File lib/tickets.rb, line 44
44:     def list_closed
45:       @trac.query("ticket.query","status=closed")
46:     end

adds an attachment to a ticket

[Source]

     # 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

[Source]

     # 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

[Source]

    # 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

[Validate]