Module: RakeDocker::Output
- Defined in:
- lib/rake_docker/output.rb
Class Method Summary collapse
Class Method Details
.parse(chunk) ⇒ Object
6 7 8 9 10 |
# File 'lib/rake_docker/output.rb', line 6 def self.parse(chunk) chunk.each_line do |line| yield self.parse_line(line) end end |
.parse_line(line) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/rake_docker/output.rb', line 12 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 |
.print(chunk) ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/rake_docker/output.rb', line 39 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 |