<commit_before>module Combustion
  class Database
    def self.setup
      silence_stream(STDOUT) do
        reset_database
        load_schema
        migrate
      end
    end

    def self.reset_database
      ActiveRecord::Base.configurations = YAML.load(ERB.new(File.read("#{Rails.root}/config/database.yml")).result)
      abcs = ActiveRecord::Base.configurations
      case abcs['test']['adapter']
      when /mysql/
        drop_database(abcs['test']['database'])
        create_database(abcs['test'])
        ActiveRecord::Base.establish_connection(:test)
      when /postgresql/
        ActiveRecord::Base.clear_active_connections!
        drop_database(abcs['test'])
        create_database(abcs['test'])
      when /sqlite/
        drop_database(abcs['test'])
        create_database(abcs['test'])
      when 'sqlserver'
        test = abcs.deep_dup['test']
        test_database = test['database']
        test['database'] = 'master'<commit_msg>Remove silence_stream for rails 5 compatibility<commit_after>module Combustion
  class Database
    def self.setup
      reset_database
      load_schema
      migrate
    end

    def self.reset_database
      ActiveRecord::Base.configurations = YAML.load(ERB.new(File.read("#{Rails.root}/config/database.yml")).result)
      abcs = ActiveRecord::Base.configurations
      case abcs['test']['adapter']
      when /mysql/
        drop_database(abcs['test']['database'])
        create_database(abcs['test'])
        ActiveRecord::Base.establish_connection(:test)
      when /postgresql/
        ActiveRecord::Base.clear_active_connections!
        drop_database(abcs['test'])
        create_database(abcs['test'])
      when /sqlite/
        drop_database(abcs['test'])
        create_database(abcs['test'])
      when 'sqlserver'
        test = abcs.deep_dup['test']
        test_database = test['database']
        test['database'] = 'master'
{'fraction_non_alphanumeric': 0.12302839116719243, 'fraction_numerical': 0.0005257623554153522, 'mean_word_length': 2.939958592132505, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3595991', 'n_tokens_mistral': 560, 'n_tokens_neox': 549, 'n_words': 87}