Class: TaaS::OutputParser

Inherits:
Object
  • Object
show all
Defined in:
lib/helper/output_parser.rb

Class Method Summary collapse

Class Method Details

.parse_server_output(response_body) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/helper/output_parser.rb', line 8

def self.parse_server_output(response_body)
  return nil unless valid_server_response?(response_body)
  body = response_body.scan(/<Taas-Output>(.*)<\/TaaS-Output>/m).first.first
  response_json = response_body.scan(/<TaaS-Json>(.*)<\/TaaS-Json>/m).first.first
  response_hash = JSON.parse(response_json) rescue nil
  return nil if response_hash.nil?
  return response_hash,body
end

.parse_taas_output(output) ⇒ Object



4
5
6
# File 'lib/helper/output_parser.rb', line 4

def self.parse_taas_output(output)
  output.scan(/<TaaS Response Start>(.*)<TaaS Response Complete>/m).first.first rescue nil
end

.valid_server_response?(response) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/helper/output_parser.rb', line 17

def self.valid_server_response?(response)
  !(response.scan(/<Taas-Output>(.*)<\/TaaS-Output>/m).empty? || response.scan(/<TaaS-Json>(.*)<\/TaaS-Json>/m).empty?)
end