<commit_before>namespace :yaml_dump do
  desc "Dump the database to a .yaml file using YAML"

  desc 'Create YAML test fixtures from data in an existing database. Defaults to development database.  Set RAILS_ENV to override.'
  task :dump => :environment do
    sql  = "SELECT * FROM %s"
    skip_tables = ["schema_info","schema_migrations"]
    ActiveRecord::Base.establish_connection
    (ActiveRecord::Base.connection.tables - skip_tables).each do |table_name|
      i = "000"
      data = ActiveRecord::Base.connection.select_all(sql % table_name)
      if data.count > 0
        filename = "%s/spec/fixtures/%s.yml" % [Rails.root, table_name]
        File.open(filename, 'w') do |file|
          puts "Writing ./spec/fixtures/%s.yml with [%d] rows." % [table_name, data.count]
          file.write data.inject({}) { |hash, record|
            hash["#{table_name}_#{i.succ!}"] = record
            hash
          }.to_yaml<commit_msg>changed the default dump directory<commit_after>namespace :yaml_dump do
  desc "Dump the database to a .yaml file using YAML"

  desc 'Create YAML test fixtures from data in an existing database. Defaults to development database.  Set RAILS_ENV to override.'
  task :dump => :environment do
    sql  = "SELECT * FROM %s"
    skip_tables = ["schema_info","schema_migrations"]
    ActiveRecord::Base.establish_connection
    (ActiveRecord::Base.connection.tables - skip_tables).each do |table_name|
      i = "000"
      data = ActiveRecord::Base.connection.select_all(sql % table_name)
      if data.count > 0
        filename = "%s/fixture_dump/%s.yml" % [Rails.root, table_name]
        File.open(filename, 'w') do |file|
          puts "Writing ./fixture_dump/%s.yml with [%d] rows." % [table_name, data.count]
          file.write data.inject({}) { |hash, record|
            hash["#{table_name}_#{i.succ!}"] = record
            hash
          }.to_yaml
{'fraction_non_alphanumeric': 0.12453825857519789, 'fraction_numerical': 0.004221635883905013, 'mean_word_length': 3.0254777070063694, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '2816519', 'n_tokens_mistral': 601, 'n_tokens_neox': 580, 'n_words': 161}