Object
returns the actions that can be performed on the ticket
# File lib/trac4r/tickets.rb, line 143 def actions ticket_id @trac.query("ticket.getAvailableActions",ticket_id) end
returns a list of attachments for the given ticket
# File lib/trac4r/tickets.rb, line 123 def attachments ticket_id @trac.query("ticket.listAttachments",ticket_id) 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/trac4r/tickets.rb, line 113 def changelog ticket_id,w=0 @trac.query("ticket.changeLog",ticket_id,w) end
returns a list of ids of tickets that have changed since `time’
# File lib/trac4r/tickets.rb, line 118 def changes time @trac.query("ticket.getRecentChanges",time) end
create a new ticket returning the ticket id
# File lib/trac4r/tickets.rb, line 88 def create summary,description,attributes={ },notify=false @trac.query("ticket.create",summary,description,attributes,notify) end
delete ticket by id
# File lib/trac4r/tickets.rb, line 104 def delete id @trac.query("ticket.delete",id) end
deletes given attachment
# File lib/trac4r/tickets.rb, line 138 def delete_attachment ticket_id,filename @trac.query("ticket.deleteAttachment",ticket_id,filename) end
fetch a ticket. Returns instance of Trac::Ticket
# File lib/trac4r/tickets.rb, line 83 def get id Ticket.load @trac.query("ticket.get",id) 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/trac4r/tickets.rb, line 65 def get_all options={ } include_closed = options[:include_closed] || true cached_results = options[:cached_results] || true if(cached_results == true && @cache_last_update && @cache_last_update > Time.now - 300) return @cache end tickets = { } list(:include_closed => include_closed).each do |ticket| tickets[ticket] = get ticket end @cache = tickets @cache_last_update = Time.now return tickets end
returns the content of an attachment
# File lib/trac4r/tickets.rb, line 128 def get_attachment ticket_id,filename @trac.query("ticket.getAttachment",ticket_id,filename) end
returns the settings in the same form as Tickets#settings, but refreshes them every time we call it.
# File lib/trac4r/tickets.rb, line 160 def get_settings @settings = { } ['status','version','priority','resolution', 'component','type','severity','milestone'].each do |setting| @settings[setting.to_sym] = @trac.query("ticket.#{setting}.getAll") end return @settings 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/trac4r/tickets.rb, line 36 def list options={ } include_closed = true include_closed = options[:include_closed] if !options[:include_closed].nil? tickets = query(:status => "!closed") tickets += query(:status => "closed") if include_closed return tickets end
like `list’, but only gets closed tickets
# File lib/trac4r/tickets.rb, line 54 def list_closed query(:status => "closed") end
adds an attachment to a ticket
# File lib/trac4r/tickets.rb, line 133 def put_attachment ticket_id,filename,description,data,replace=true @trac.query("ticket.putAttachment",ticket_id,filename,description,data,replace) end
Run an arbitrary ticket query
a hash of options, each should use a symbol or string
as the key and a symbol/string or array of symbols/strings as the value. If the value starts with a +!+, it will be treated as a not equal. Multiple values mean “or”, as in any value may match
# File lib/trac4r/tickets.rb, line 49 def query(args) @trac.query("ticket.query",args_to_trac_args(args)) 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/trac4r/tickets.rb, line 153 def settings @settings || get_settings end
update ticket returning the ticket in the same orm as ticket.get
# File lib/trac4r/tickets.rb, line 93 def update id,comment,attributes={ },notify=false attr = {} attributes.each_pair do |key, value| unless(value.nil? || value.size == 0 || value.empty?) attr[key] = value end end @trac.query("ticket.update",id,comment,attr,notify) end
Generated with the Darkfish Rdoc Generator 2.