Module: Straycall::Reporter::Protocol
- Defined in:
- lib/straycall/reporter/protocol.rb
Defined Under Namespace
Classes: Reader
Class Method Summary collapse
- .backtrace_request(tid) ⇒ Object
- .backtrace_response(tid, backtrace) ⇒ Object
- .example(value) ⇒ Object
- .parse(line) ⇒ Object
- .sync_request ⇒ Object
Class Method Details
.backtrace_request(tid) ⇒ Object
40 41 42 |
# File 'lib/straycall/reporter/protocol.rb', line 40 def backtrace_request(tid) "BT #{Integer(tid)}\n" end |
.backtrace_response(tid, backtrace) ⇒ Object
44 45 46 47 |
# File 'lib/straycall/reporter/protocol.rb', line 44 def backtrace_response(tid, backtrace) payload = backtrace ? JSON.generate(backtrace) : "-" "BT #{Integer(tid)} #{payload}\n" end |
.example(value) ⇒ Object
49 50 51 |
# File 'lib/straycall/reporter/protocol.rb', line 49 def example(value) "EXAMPLE #{JSON.generate(value)}\n" end |
.parse(line) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/straycall/reporter/protocol.rb', line 57 def parse(line) type, rest = line.to_s.chomp.split(" ", 2) case type when "BT" tid, payload = rest.to_s.split(" ", 2) [:backtrace, Integer(tid), payload && payload != "-" ? JSON.parse(payload) : nil] when "EXAMPLE" [:example, JSON.parse(rest, symbolize_names: true)] when "VIOLATION" [:violation] when "SYNC" [:sync] when "OK" [:ack] else [:unknown] end rescue ArgumentError, JSON::ParserError [:unknown] end |
.sync_request ⇒ Object
53 54 55 |
# File 'lib/straycall/reporter/protocol.rb', line 53 def sync_request "SYNC\n" end |