Class: TapOut::JsonParser
- Inherits:
-
Object
- Object
- TapOut::JsonParser
- Defined in:
- lib/tapout/parsers/json.rb
Overview
The TAP-J Parser takes a TAP-J stream and routes it through a TapOut report format.
Instance Method Summary collapse
- #<<(line) ⇒ Object
- #consume(input) ⇒ Object
- #handle(doc) ⇒ Object
-
#initialize(options = {}) ⇒ JsonParser
constructor
A new instance of JsonParser.
Constructor Details
#initialize(options = {}) ⇒ JsonParser
Returns a new instance of JsonParser.
12 13 14 15 |
# File 'lib/tapout/parsers/json.rb', line 12 def initialize(={}) format = [:format] @reporter = Reporters.factory(format).new end |
Instance Method Details
#<<(line) ⇒ Object
26 27 28 |
# File 'lib/tapout/parsers/json.rb', line 26 def <<(line) handle(line) end |
#consume(input) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/tapout/parsers/json.rb', line 18 def consume(input) while line = input.gets self << line end @reporter.finalize end |
#handle(doc) ⇒ Object
31 32 33 34 35 |
# File 'lib/tapout/parsers/json.rb', line 31 def handle(doc) return if doc == '' entry = JSON.load(doc) @reporter << entry end |