# File lib/hammer_cli/output/adapter/csv.rb, line 23 def print_collection(fields, collection) csv_string = generate do |csv| # labels csv << fields.select{ |f| !(f.class <= Fields::Id) || @context[:show_ids] }.map { |f| f.label } # data collection.each do |d| csv << fields.inject([]) do |row, f| unless f.class <= Fields::Id && !@context[:show_ids] value = data_for_field(f, d) formatter = @formatters.formatter_for_type(f.class) row << ((formatter ? formatter.format(value) : value) || '') end row end end end puts csv_string end
# File lib/hammer_cli/output/adapter/csv.rb, line 42 def print_message(msg, msg_params={}) csv_string = generate do |csv| id = msg_params["id"] || msg_params[:id] name = msg_params["name"] || msg_params[:name] labels = [_("Message")] data = [msg.format(msg_params)] if id labels << _("Id") data << id end if name labels << _("Name") data << name end csv << labels csv << data end puts csv_string end
Generated with the Darkfish Rdoc Generator 2.