<commit_before>
#
# testing ruote-sequel
#
# Thu Feb 10 11:14:56 JST 2011
#

require 'rufus-json/automatic'
require 'ruote-sequel'


unless $sequel

  $sequel = case ENV['RUOTE_STORAGE_DB'] || 'postgres'
    when 'pg', 'postgres'
      Sequel.connect('postgres://localhost/ruote_test')
    when 'my', 'mysql'
      #Sequel.connect('mysql://root:root@localhost/ruote_test')
      Sequel.connect('mysql://root@localhost/ruote_test')
    when /:/
      Sequel.connect(ENV['RUOTE_STORAGE_DB'])
    else
      raise ArgumentError.new("unknown DB: #{ENV['RUOTE_STORAGE_DB'].inspect}")
  end

  Ruote::Sequel.create_table($sequel, true)
    # true forces re_create of 'documents' table

  require 'logger'

  logger = case ENV['RUOTE_STORAGE_DEBUG']
    when 'log'
      FileUtils.rm('debug.log') rescue nil
      Logger.new('debug.log')
    when 'stdout'
      Logger.new($stdout)
    else
      nil
  end

  if logger
    logger.level = Logger::DEBUG
    $sequel.loggers << logger
  end
end


def new_storage(opts)

  Ruote::Sequel::Storage.new($sequel, opts)
end

<commit_msg>log as soon as possible<commit_after>
#
# testing ruote-sequel
#
# Thu Feb 10 11:14:56 JST 2011
#

require 'rufus-json/automatic'
require 'ruote-sequel'


unless $sequel

  $sequel = case ENV['RUOTE_STORAGE_DB'] || 'postgres'
    when 'pg', 'postgres'
      Sequel.connect('postgres://localhost/ruote_test')
    when 'my', 'mysql'
      #Sequel.connect('mysql://root:root@localhost/ruote_test')
      Sequel.connect('mysql://root@localhost/ruote_test')
    when /:/
      Sequel.connect(ENV['RUOTE_STORAGE_DB'])
    else
      raise ArgumentError.new("unknown DB: #{ENV['RUOTE_STORAGE_DB'].inspect}")
  end

  require 'logger'

  logger = case ENV['RUOTE_STORAGE_DEBUG']
    when 'log'
      FileUtils.rm('debug.log') rescue nil
      Logger.new('debug.log')
    when 'stdout'
      Logger.new($stdout)
    else
      nil
  end

  if logger
    logger.level = Logger::DEBUG
    $sequel.loggers << logger
  end

  Ruote::Sequel.create_table($sequel, true)
    # true forces re_create of 'documents' table
end


def new_storage(opts)

  Ruote::Sequel::Storage.new($sequel, opts)
end


{'fraction_non_alphanumeric': 0.1392757660167131, 'fraction_numerical': 0.011142061281337047, 'mean_word_length': 3.443298969072165, 'pattern_counts': {'":': 0, '<': 7, '<?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': '4396431', 'n_tokens_mistral': 825, 'n_tokens_neox': 763, 'n_words': 152}