def print_collection(all_fields, collection)
fields = field_filter.filter(all_fields)
rows = collection.collect do |d|
row = {}
fields.each do |f|
row[label_for(f)] = WrapperFormatter.new(
@formatters.formatter_for_type(f.class), f.parameters).format(data_for_field(f, d) || "")
end
row
end
options = fields.collect do |f|
{ label_for(f) => {
:width => max_width_for(f)
}
}
end
sort_order = fields.map { |f| f.label.upcase }
printer = TablePrint::Printer.new(rows, options)
TablePrint::Config.max_width = MAX_COLUMN_WIDTH
TablePrint::Config.multibyte = true
output = sort_columns(printer.table_print, sort_order)
dashes = /\n([-|]+)\n/.match(output)
puts dashes[1] if dashes
puts output
puts dashes[1] if dashes
end