Abstract
# File lib/hammer_cli/output/adapter/csv.rb, line 151 def print_collection(fields, collection) rows = row_data(fields, collection) # get headers using columns heuristic headers = rows.map{ |r| Cell.headers(r, @context) }.max_by{ |headers| headers.size } # or use headers from output definition headers ||= default_headers(fields) csv_string = generate do |csv| csv << headers if headers rows.each do |row| csv << Cell.values(headers, row) end end puts csv_string end
# File lib/hammer_cli/output/adapter/csv.rb, line 166 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.