Parent

Files

Class/Module Index [+]

Quicksearch

Trac::Tickets

Public Class Methods

new(trac) click to toggle source
# File lib/trac4r/tickets.rb, line 28
def initialize trac
  @trac = trac
end

Public Instance Methods

actions(ticket_id) click to toggle source

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
attachments(ticket_id) click to toggle source

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
changelog(ticket_id,w=0) click to toggle source

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
changes(time) click to toggle source

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(summary,description,attributes={ }) click to toggle source

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(id) click to toggle source

delete ticket by id

# File lib/trac4r/tickets.rb, line 104
def delete id
  @trac.query("ticket.delete",id)
end
delete_attachment(ticket_id,filename) click to toggle source

deletes given attachment

# File lib/trac4r/tickets.rb, line 138
def delete_attachment ticket_id,filename
  @trac.query("ticket.deleteAttachment",ticket_id,filename)
end
get(id) click to toggle source

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
get_all(options={ }) click to toggle source

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
get_attachment(ticket_id,filename) click to toggle source

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
get_settings() click to toggle source

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
list(options={ }) click to toggle source

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
list_closed() click to toggle source

like `list’, but only gets closed tickets

# File lib/trac4r/tickets.rb, line 54
def list_closed
  query(:status => "closed")
end
put_attachment(ticket_id,filename,description,data,replace=true) click to toggle source

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
query(args) click to toggle source

Run an arbitrary ticket query

args

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
settings() click to toggle source

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(id,comment,attributes={ }) click to toggle source

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

[Validate]

Generated with the Darkfish Rdoc Generator 2.