Class: Bigrig::OutputParser

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeOutputParser

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_procObject



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