<commit_before># Mix this in with the responder object to respond to CSV
# Overwrite csv_header to cusomize the CSV header
# Overwrite collection_csv to customize collection output

module Yogo
  module Responders
    module Csv
      def to_csv
        case(resource)
        when ::DataMapper::Collection
          controller.send_data(csv_header(resource) + collection_csv(resource), :type => :csv)
        when ::DataMapper::Resource
          controller.send_data(csv_header(resource) + resource.to_csv, :type => :csv)
        else
          to_format
        end<commit_msg>add good filenames to csv files<commit_after># Mix this in with the responder object to respond to CSV
# Overwrite csv_header to cusomize the CSV header
# Overwrite collection_csv to customize collection output

module Yogo
  module Responders
    module Csv
      def to_csv
        case(resource)
        when ::DataMapper::Collection
          controller.send_data(csv_header(resource) + collection_csv(resource), 
            :filename => resource.collection.name + '.csv', :type => :csv)
        when ::DataMapper::Resource
          controller.send_data(csv_header(resource) + resource.to_csv, 
            :filename => resource.to_s + '.csv',  :type => :csv)
        else
          to_format
        end
{'fraction_non_alphanumeric': 0.07829457364341086, 'fraction_numerical': 0.0, 'mean_word_length': 2.9359756097560976, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1044976', 'n_tokens_mistral': 360, 'n_tokens_neox': 346, 'n_words': 108}