Class: OnesnooperServer::PayloadParser
- Inherits:
-
Object
- Object
- OnesnooperServer::PayloadParser
- Defined in:
- lib/onesnooper_server/payload_parser.rb
Overview
Central parsing class for decoding and analyzing the content of incoming monitoring messages. Implements one publicly available method ‘parse(payload)`. Internally, the payload is decoded from Base64 and parsed into a hash-like structure.
Constant Summary collapse
- TRIM_CLEANUP =
/\s*/
- KEY =
/[[[:upper:]]|[[:digit:]]|_]+/
- VALUE =
/[[[:alnum:]]|_|\-|\.|:]+/
- QUOTED_VALUE =
/.+/
- HASH_VALUE =
/[^\]]+/
- EQUALS =
/#{TRIM_CLEANUP}=#{TRIM_CLEANUP}/
- KEY_HASH_VALUE_REGEXP =
/#{TRIM_CLEANUP}^#{TRIM_CLEANUP}(?<key>#{KEY})#{EQUALS}\[(?<value>#{HASH_VALUE})\]#{TRIM_CLEANUP}$#{TRIM_CLEANUP}/m
- KEY_QUOTED_VALUE_REGEXP =
/#{TRIM_CLEANUP}^#{TRIM_CLEANUP}(?<key>#{KEY})#{EQUALS}"(?<value>#{QUOTED_VALUE})"#{TRIM_CLEANUP}$#{TRIM_CLEANUP}/
- KEY_RAW_VALUE_REGEXP =
/#{TRIM_CLEANUP}^#{TRIM_CLEANUP}(?<key>#{KEY})#{EQUALS}(?<value>#{VALUE})#{TRIM_CLEANUP}$#{TRIM_CLEANUP}/
Class Method Summary collapse
-
.parse(payload) ⇒ Hash
Parses given payload into a hash-like structure.
Class Method Details
.parse(payload) ⇒ Hash
Parses given payload into a hash-like structure. Payload is decoded from Base64 and then analyzed and parsed.
24 25 26 27 |
# File 'lib/onesnooper_server/payload_parser.rb', line 24 def self.parse(payload) return {} if payload.blank? analyze(decode(payload)) end |