class Dockit::Log
Public Class Methods
print_chunk(chunk)
click to toggle source
new docker app (xhyve) returns multi-line (multiple JSON hash) chunks. So, split them up before trying to parse them.
# File lib/dockit.rb, line 23 def print_chunk(chunk) chunk.each_line { |c| print_one_chunk(c) } end
Private Class Methods
print_one_chunk(chunk)
click to toggle source
# File lib/dockit.rb, line 28 def print_one_chunk(chunk) begin chunk = JSON.parse(chunk) rescue Docker::Error::UnexpectedResponseError => e $stderr.puts "Unexpected response:", e.message, chunk rescue JSON::ParserError $stderr.puts "Parse Error: #{chunk}" end progress = chunk['progress'] id = progress ? '' : chunk['id'] $stdout.puts( if chunk['errorDetail'] 'ERROR: ' + chunk['errorDetail']['message'] elsif chunk['stream'] chunk['stream'] else [chunk['status'], id, progress, progress ? "\r" : "\n"].join(' ') end ) end
Public Instance Methods
debug(msg)
click to toggle source
# File lib/dockit.rb, line 17 def debug(msg) $stderr.puts "DEBUG: " + msg.join(' ') end