<commit_before>require 'rubygems'
gem 'rspec'
require 'spec'

$:.unshift(File.dirname(__FILE__) + '/../lib')

if ENV['RAILS_GEM_VERSION'] =~ /^2.0/
  gem 'activerecord', '=2.0.2'
  gem 'actionpack', '=2.0.2'
  gem 'activesupport', '=2.0.2'
  gem 'composite_primary_keys', '=0.9.93'
elsif ENV['RAILS_GEM_VERSION'] =~ /^2.1/
  gem 'activerecord', '=2.1.2'
  gem 'actionpack', '=2.1.2'
  gem 'activesupport', '=2.1.2'
  gem 'composite_primary_keys', '=1.0.8'
elsif ENV['RAILS_GEM_VERSION'] =~ /^2.2/
  gem 'activerecord', '=2.2.2'
  gem 'actionpack', '=2.2.2'
  gem 'activesupport', '=2.2.2'
  gem 'composite_primary_keys', '=2.2.2'
elsif ENV['RAILS_GEM_VERSION'] =~ /^2.3.3/
  gem 'activerecord', '=2.3.3'
  gem 'actionpack', '=2.3.3'
  gem 'activesupport', '=2.3.3'
  gem 'composite_primary_keys', '=2.3.2'
elsif ENV['RAILS_GEM_VERSION'] =~ /^2.3/
  gem 'activerecord', '=2.3.5'
  gem 'actionpack', '=2.3.5'
  gem 'activesupport', '=2.3.5'
  NO_COMPOSITE_PRIMARY_KEYS = true
else
  # uses local copy of Rails 3 gems
  ['rails/activerecord', 'rails/activemodel', 'rails/activesupport', 'arel', 'rails/actionpack', 'rails/railties'].each do |library|
    $:.unshift(File.expand_path(File.dirname(__FILE__) + '/../../' + library + '/lib'))
  end
  ENV['RAILS_GEM_VERSION'] ||= '3.0'
  NO_COMPOSITE_PRIMARY_KEYS = true
end

require 'active_record'

if ENV['RAILS_GEM_VERSION'] >= '3.0'
  require 'action_dispatch'
  require "rails/subscriber"
  require 'active_record/railties/subscriber'
  require 'logger'
elsif ENV['RAILS_GEM_VERSION'] =~ /^2.3/
  require 'action_pack'
  require 'action_controller/session/abstract_store'
  require 'active_record/session_store'
elsif ENV['RAILS_GEM_VERSION'] <= '2.3'
  require 'action_pack'
  require 'action_controller/session/active_record_store'
end
if !defined?(RUBY_ENGINE) || RUBY_ENGINE == 'ruby'
  gem 'ruby-oci8', '>=2.0.4'
  require 'oci8'
elsif RUBY_ENGINE == 'jruby'
  gem 'activerecord-jdbc-adapter'
  require 'active_record/connection_adapters/jdbc_adapter'
end

require 'active_record/connection_adapters/oracle_enhanced_adapter'
require 'ruby-plsql'

module LoggerSpecHelper
  def set_logger
    @logger = MockLogger.new

    if ENV['RAILS_GEM_VERSION'] >= '3.0'
      queue = ActiveSupport::Notifications::Fanout.new
      @notifier = ActiveSupport::Notifications::Notifier.new(queue)

      Rails::Subscriber.colorize_logging = false
      @notifier.subscribe { |*args| Rails::Subscriber.dispatch(args) }

      Rails::Subscriber.add(:active_record, ActiveRecord::Railties::Subscriber.new) \
        unless Rails::Subscriber.subscribers[:active_record]

      ActiveRecord::Base.logger = @logger
      ActiveSupport::Notifications.notifier = @notifier

    else # ActiveRecord 2.x
      if ActiveRecord::Base.respond_to?(:connection_pool)
        ActiveRecord::Base.connection_pool.clear_reloadable_connections!
      else
        ActiveRecord::Base.clear_active_connections!
      end
      ActiveRecord::Base.logger = @logger
      ActiveRecord::Base.colorize_logging = false
      # ActiveRecord::Base.logger.level = Logger::DEBUG
    end

  end

  class MockLogger
    attr_reader :flush_count

    def initialize
      @flush_count = 0
      @logged = Hash.new { |h,k| h[k] = [] }
    end

    # used in AtiveRecord 2.x
    def debug?
      true
    end

    def method_missing(level, message)
      @logged[level] << message
    end
<commit_msg>fixed LoggerSpecHelper according to latest Rails 3 edge version<commit_after>require 'rubygems'
gem 'rspec'
require 'spec'

$:.unshift(File.dirname(__FILE__) + '/../lib')

if ENV['RAILS_GEM_VERSION'] =~ /^2.0/
  gem 'activerecord', '=2.0.2'
  gem 'actionpack', '=2.0.2'
  gem 'activesupport', '=2.0.2'
  gem 'composite_primary_keys', '=0.9.93'
elsif ENV['RAILS_GEM_VERSION'] =~ /^2.1/
  gem 'activerecord', '=2.1.2'
  gem 'actionpack', '=2.1.2'
  gem 'activesupport', '=2.1.2'
  gem 'composite_primary_keys', '=1.0.8'
elsif ENV['RAILS_GEM_VERSION'] =~ /^2.2/
  gem 'activerecord', '=2.2.2'
  gem 'actionpack', '=2.2.2'
  gem 'activesupport', '=2.2.2'
  gem 'composite_primary_keys', '=2.2.2'
elsif ENV['RAILS_GEM_VERSION'] =~ /^2.3.3/
  gem 'activerecord', '=2.3.3'
  gem 'actionpack', '=2.3.3'
  gem 'activesupport', '=2.3.3'
  gem 'composite_primary_keys', '=2.3.2'
elsif ENV['RAILS_GEM_VERSION'] =~ /^2.3/
  gem 'activerecord', '=2.3.5'
  gem 'actionpack', '=2.3.5'
  gem 'activesupport', '=2.3.5'
  NO_COMPOSITE_PRIMARY_KEYS = true
else
  # uses local copy of Rails 3 gems
  ['rails/activerecord', 'rails/activemodel', 'rails/activesupport', 'arel', 'rails/actionpack', 'rails/railties'].each do |library|
    $:.unshift(File.expand_path(File.dirname(__FILE__) + '/../../' + library + '/lib'))
  end
  ENV['RAILS_GEM_VERSION'] ||= '3.0'
  NO_COMPOSITE_PRIMARY_KEYS = true
end

require 'active_record'

if ENV['RAILS_GEM_VERSION'] >= '3.0'
  require 'action_dispatch'
  require 'active_support/core_ext/module/attribute_accessors'
  require "rails/log_subscriber"
  require 'active_record/railties/log_subscriber'
  require 'logger'
elsif ENV['RAILS_GEM_VERSION'] =~ /^2.3/
  require 'action_pack'
  require 'action_controller/session/abstract_store'
  require 'active_record/session_store'
elsif ENV['RAILS_GEM_VERSION'] <= '2.3'
  require 'action_pack'
  require 'action_controller/session/active_record_store'
end
if !defined?(RUBY_ENGINE) || RUBY_ENGINE == 'ruby'
  gem 'ruby-oci8', '>=2.0.4'
  require 'oci8'
elsif RUBY_ENGINE == 'jruby'
  gem 'activerecord-jdbc-adapter'
  require 'active_record/connection_adapters/jdbc_adapter'
end

require 'active_record/connection_adapters/oracle_enhanced_adapter'
require 'ruby-plsql'

module LoggerSpecHelper
  def set_logger
    @logger = MockLogger.new

    if ENV['RAILS_GEM_VERSION'] >= '3.0'
      queue = ActiveSupport::Notifications::Fanout.new
      @notifier = ActiveSupport::Notifications::Notifier.new(queue)

      Rails::LogSubscriber.colorize_logging = false

      ActiveRecord::Base.logger = @logger
      ActiveSupport::Notifications.notifier = @notifier

      Rails::LogSubscriber.add(:active_record, ActiveRecord::Railties::LogSubscriber.new)

    else # ActiveRecord 2.x
      if ActiveRecord::Base.respond_to?(:connection_pool)
        ActiveRecord::Base.connection_pool.clear_reloadable_connections!
      else
        ActiveRecord::Base.clear_active_connections!
      end
      ActiveRecord::Base.logger = @logger
      ActiveRecord::Base.colorize_logging = false
      # ActiveRecord::Base.logger.level = Logger::DEBUG
    end

  end

  class MockLogger
    attr_reader :flush_count

    def initialize
      @flush_count = 0
      @logged = Hash.new { |h,k| h[k] = [] }
    end

    # used in AtiveRecord 2.x
    def debug?
      true
    end

    def method_missing(level, message)
      @logged[level] << message
    end

{'fraction_non_alphanumeric': 0.15201411349603058, 'fraction_numerical': 0.026021758306380476, 'mean_word_length': 4.099700149925037, 'pattern_counts': {'":': 0, '<': 9, '<?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': '3784508', 'n_tokens_mistral': 2672, 'n_tokens_neox': 2559, 'n_words': 461}