Sha256: 234bd5bd7312d5d006a05447f68084222b93793a603749ba20687dbb5c2a1252
Contents?: true
Size: 1.05 KB
Versions: 43
Compression:
Stored size: 1.05 KB
Contents
require 'json' require 'colored2' module RakeDocker module Output def self.parse(chunk) chunk.each_line do |line| yield self.parse_line(line) end end def self.parse_line(line) begin json = JSON.parse(line.strip) rescue JSON::ParserError return line end # Skip progress and aux as they are covered by other status messages return '' if json['progress'] && json['status'] return '' if json['aux'] # Return error flag as a second result return [json['error'], true] if json['error'] return json['stream'] if json['stream'] if json['status'] if json['id'] return json['id'] + ': ' + json['status'] + "\n" else return json['status'] + "\n" end end return line end def self.print(chunk) self.parse(chunk) do |text, is_error| if is_error $stdout.print text.red + "\n" raise text end $stdout.print text unless text.empty? end end end end
Version data entries
43 entries across 43 versions & 1 rubygems