Class: Fiddler::Parsers::TicketParser

Inherits:
BaseParser
  • Object
show all
Defined in:
lib/fiddler/parsers/ticket_parser.rb

Constant Summary

Constants inherited from BaseParser

BaseParser::ERROR_CODES, BaseParser::SUCCESS_CODES

Class Method Summary collapse

Methods inherited from BaseParser

check_response_code, tokenize_response

Class Method Details

.parse_change_ownership_response(response) ⇒ Object



30
31
32
33
34
35
36
37
# File 'lib/fiddler/parsers/ticket_parser.rb', line 30

def self.parse_change_ownership_response(response)
   response = check_response_code(response)
   if response.first =~ /^# Owner changed from (\S+) to (\S+)/
      return $2
   else
      return nil
   end
end

.parse_multiple(response) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/fiddler/parsers/ticket_parser.rb', line 10

def self.parse_multiple(response)
   response = check_response_code(response)
   response = check_for_errors(response)
   if response.count == 0
      []
   else
      ticket_token_responses = tokenize_response(response)
      tickets = Array.new
      ticket_token_responses.each do |token_response|
         tickets << ticket_from_response(token_response)
      end
      tickets
   end
end

.parse_reply_response(response) ⇒ Object



25
26
27
28
# File 'lib/fiddler/parsers/ticket_parser.rb', line 25

def self.parse_reply_response(response)
   response = check_response_code(response)
   return !response.first.match(/^# Message recorded/).nil?
end

.parse_single(response) ⇒ Object



4
5
6
7
8
# File 'lib/fiddler/parsers/ticket_parser.rb', line 4

def self.parse_single(response)
   response = check_response_code(response)
   response = check_for_errors(response)
   ticket_from_response(response)
end

.parse_update_response(response, method) ⇒ Object



39
40
41
42
43
44
45
46
# File 'lib/fiddler/parsers/ticket_parser.rb', line 39

def self.parse_update_response(response, method)
   response = check_response_code(response)
   if method == :create
      return response.first =~ /^# Ticket (\S+) created/ ? $1 : nil
   elsif method == :update
      return response.first =~ /^# Ticket (\S+) updated/ ? $1 : nil
   end
end