#!/usr/bin/env ruby $pfix = '' $ffix = '' $body = '' def flush if $pfix != '' puts 'Packages installed:' puts $pfix.split("\n").sort.join("\n") end if $ffix != '' puts 'Files affected:' puts $ffix.split("\n").sort.join("\n") end puts $body $pfix = '' $ffix = '' $body = '' end STDIN.each_line do |line| if line.start_with? "p*" $pfix += line[1,line.length] elsif line.start_with? "f*" $ffix += line[1,line.length] elsif line.start_with? '=' flush puts line else $body += line end end flush