Class: FPM::Fry::BuildOutputParser

Inherits:
Struct
  • Object
show all
Defined in:
lib/fpm/fry/build_output_parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*_) ⇒ BuildOutputParser

Returns a new instance of BuildOutputParser.



7
8
9
10
# File 'lib/fpm/fry/build_output_parser.rb', line 7

def initialize(*_)
  super
  @images = []
end

Instance Attribute Details

#imagesObject (readonly)

Returns the value of attribute images.



5
6
7
# File 'lib/fpm/fry/build_output_parser.rb', line 5

def images
  @images
end

#outObject

Returns the value of attribute out

Returns:

  • (Object)

    the current value of out



3
4
5
# File 'lib/fpm/fry/build_output_parser.rb', line 3

def out
  @out
end

Instance Method Details

#call(chunk, *_) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/fpm/fry/build_output_parser.rb', line 12

def call(chunk, *_)
  # new docker for Mac results in data like this:
  # "{'stream':' ---\\u003e 3bc51d6a4c46\\n'}\r\n{'stream':'Step 2 : WORKDIR /tmp/build\\n'}\r\n"
  # this isn't valid JSON, of course, so we process each part individually
  chunk.split("\r\n").each do |sub_chunk|
    json = JSON.parse(sub_chunk)
    stream = json['stream']
    if /\ASuccessfully built (\w+)\Z/.match(stream)
      images << $1
    end
    out << stream
  end
end