<commit_before>ENV['RAILS_ENV'] = 'test'

require 'bundler'
Bundler.require(:default)

require 'active_record'
require 'database_cleaner'

begin
  require './spec/support/simplecov_helper'
  include SimpleCovHelper
  start_simple_cov("unit-#{RUBY_VERSION}")
rescue LoadError
  puts "Coverage disabled."
end

jruby = defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby'

$adapter = ENV['ADAPTER'] || 'postgresql'
$adapter = 'jdbc' + $adapter if jruby

DATABASE_CONFIG = YAML.load_file(File.expand_path("../config/database.yml", File.dirname(__FILE__)))

if DATABASE_CONFIG[$adapter].nil?
  puts "No such adapter '#{$adapter}'. Valid adapters are #{DATABASE_CONFIG.keys.join(', ')}."
  exit 1
end

if ENV['TRAVIS']
  DATABASE_CONFIG[$adapter]['username'] = 'postgres'
else
  require 'etc'
  username = $adapter =~ /mysql/ ? 'root' : Etc.getlogin
  DATABASE_CONFIG[$adapter]['username'] = username
end

puts "Using #{$adapter} adapter."
<commit_msg>Disable coverage for Rails 4 on Travis, it's reporting incorrect numbers.<commit_after>ENV['RAILS_ENV'] = 'test'

require 'bundler'
Bundler.require(:default)

require 'active_record'
require 'database_cleaner'

unless Rails.version == '4.0.0' && ENV['TRAVIS']
  begin
    require './spec/support/simplecov_helper'
    include SimpleCovHelper
    start_simple_cov("unit-#{RUBY_VERSION}")
  rescue LoadError
    puts "Coverage disabled."
  end
end

jruby = defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby'

$adapter = ENV['ADAPTER'] || 'postgresql'
$adapter = 'jdbc' + $adapter if jruby

DATABASE_CONFIG = YAML.load_file(File.expand_path("../config/database.yml", File.dirname(__FILE__)))

if DATABASE_CONFIG[$adapter].nil?
  puts "No such adapter '#{$adapter}'. Valid adapters are #{DATABASE_CONFIG.keys.join(', ')}."
  exit 1
end

if ENV['TRAVIS']
  DATABASE_CONFIG[$adapter]['username'] = 'postgres'
else
  require 'etc'
  username = $adapter =~ /mysql/ ? 'root' : Etc.getlogin
  DATABASE_CONFIG[$adapter]['username'] = username
end

puts "Using #{$adapter} adapter."

{'fraction_non_alphanumeric': 0.15530114484818316, 'fraction_numerical': 0.0029865604778496766, 'mean_word_length': 5.4423076923076925, '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': '4299365', 'n_tokens_mistral': 738, 'n_tokens_neox': 708, 'n_words': 153}