class Ticket

Public Class Methods

new(database, id) click to toggle source
# File lib/ticket.rb, line 2
def initialize(database, id)
    @db = database
    @ticketid = id
    refresh
end

Public Instance Methods

comment_id() click to toggle source
# File lib/ticket.rb, line 34
def comment_id
    @comment_id ||= select("tkt_id")
end
comments() click to toggle source
# File lib/ticket.rb, line 44
def comments
    if(!@comments)
        old = old_comments
        res = @db.execute("select icomment from ticketchng where tkt_id is ?", comment_id)
        if(res)
            @comments = old+res.join
        else
            @comments = old+""
        end
        @comments.gsub!(/\r\n/, "\n")
    end
    @comments
end
id() click to toggle source
# File lib/ticket.rb, line 74
def id
    @ticketid
end
match(regex) click to toggle source
# File lib/ticket.rb, line 88
def match(regex)
    (comments && comments.match(regex)) || (title && title.match(regex))
end
old_comments() click to toggle source
# File lib/ticket.rb, line 38
def old_comments
    res   = select("comment")
    res ||= ""
end
priority() click to toggle source
# File lib/ticket.rb, line 58
def priority
    @priority ||= select("priority")
end
refresh() click to toggle source
# File lib/ticket.rb, line 78
def refresh
    @title      = nil
    @status     = nil
    @type       = nil
    @subsystem  = nil
    @priority   = nil
    @resolution = nil
    @comments   = nil
end
resolution() click to toggle source
# File lib/ticket.rb, line 62
def resolution
    @resolution ||= select("resolution")
end
resolve() click to toggle source
# File lib/ticket.rb, line 67
def resolve
    if(status == "Open")
        `fossil ticket set #{@ticketid} status Fixed`
        @status = nil
    end
end
select(field) click to toggle source
# File lib/ticket.rb, line 8
def select(field)
    result = nil
    @db.execute(
        "select #{field} from ticket where tkt_uuid is ?",
        @ticketid.to_s) do |val|
            result = val[0]
        end
    result
end
status() click to toggle source
# File lib/ticket.rb, line 22
def status
    @status ||= select("status")
end
subsystem() click to toggle source
# File lib/ticket.rb, line 30
def subsystem
    @subsystem ||= select("subsystem")
end
title() click to toggle source
# File lib/ticket.rb, line 18
def title
    @title ||= select("title")
end
type() click to toggle source
# File lib/ticket.rb, line 26
def type
    @type ||= select("type")
end