Class: Bigrig::OutputParser
- Inherits:
-
Object
- Object
- Bigrig::OutputParser
- Defined in:
- lib/bigrig/output_parser.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ OutputParser
constructor
A new instance of OutputParser.
- #parse(input) ⇒ Object
Constructor Details
#initialize ⇒ OutputParser
Returns a new instance of OutputParser.
7 8 9 |
# File 'lib/bigrig/output_parser.rb', line 7 def initialize @last_line = '' end |
Class Method Details
.parser_proc ⇒ Object
3 4 5 |
# File 'lib/bigrig/output_parser.rb', line 3 def self.parser_proc proc { |chunk| print OutputParser.new.parse chunk } end |
Instance Method Details
#parse(input) ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/bigrig/output_parser.rb', line 11 def parse(input) json = JSON.parse input if json['errorDetail'] "#{json['errorDetail']['message'].red}\n" elsif json['stream'] || json['id'].nil? json['stream'] || "#{json['status']}\n" else parse_progress json end end |