Class: Ticket
- Inherits:
-
Object
- Object
- Ticket
- Defined in:
- lib/ticket.rb
Instance Method Summary collapse
- #comment_id ⇒ Object
- #comments ⇒ Object
- #id ⇒ Object
-
#initialize(database, id) ⇒ Ticket
constructor
A new instance of Ticket.
- #match(regex) ⇒ Object
- #old_comments ⇒ Object
- #priority ⇒ Object
- #refresh ⇒ Object
- #resolution ⇒ Object
- #resolve ⇒ Object
- #select(field) ⇒ Object
- #status ⇒ Object
- #subsystem ⇒ Object
- #title ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize(database, id) ⇒ Ticket
Returns a new instance of Ticket.
2 3 4 5 6 |
# File 'lib/ticket.rb', line 2 def initialize(database, id) @db = database @ticketid = id refresh end |
Instance Method Details
#comment_id ⇒ Object
34 35 36 |
# File 'lib/ticket.rb', line 34 def comment_id @comment_id ||= select("tkt_id") end |
#comments ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 |
# 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 ⇒ Object
74 75 76 |
# File 'lib/ticket.rb', line 74 def id @ticketid end |
#match(regex) ⇒ Object
88 89 90 |
# File 'lib/ticket.rb', line 88 def match(regex) (comments && comments.match(regex)) || (title && title.match(regex)) end |
#old_comments ⇒ Object
38 39 40 41 |
# File 'lib/ticket.rb', line 38 def old_comments res = select("comment") res ||= "" end |
#priority ⇒ Object
58 59 60 |
# File 'lib/ticket.rb', line 58 def priority @priority ||= select("priority") end |
#refresh ⇒ Object
78 79 80 81 82 83 84 85 86 |
# File 'lib/ticket.rb', line 78 def refresh @title = nil @status = nil @type = nil @subsystem = nil @priority = nil @resolution = nil @comments = nil end |
#resolution ⇒ Object
62 63 64 |
# File 'lib/ticket.rb', line 62 def resolution @resolution ||= select("resolution") end |
#resolve ⇒ Object
67 68 69 70 71 72 |
# File 'lib/ticket.rb', line 67 def resolve if(status == "Open") `fossil ticket set #{@ticketid} status Fixed` @status = nil end end |
#select(field) ⇒ Object
8 9 10 11 12 13 14 15 16 |
# 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 ⇒ Object
22 23 24 |
# File 'lib/ticket.rb', line 22 def status @status ||= select("status") end |
#subsystem ⇒ Object
30 31 32 |
# File 'lib/ticket.rb', line 30 def subsystem @subsystem ||= select("subsystem") end |
#title ⇒ Object
18 19 20 |
# File 'lib/ticket.rb', line 18 def title @title ||= select("title") end |
#type ⇒ Object
26 27 28 |
# File 'lib/ticket.rb', line 26 def type @type ||= select("type") end |