Sha256: 3321a67c91a1e24d11c9362c697ae25bc291681cef35be3f18b94adaa737161b

Contents?: true

Size: 1.29 KB

Versions: 1

Compression:

Stored size: 1.29 KB

Contents

#
# 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 'mysql2'
        Sequel.connect(
          'mysql2://root@localhost/ruote_test',
          :after_connect => proc { |c| c.send(:reconnect=, true) })
      when /:/
        Sequel.connect(ENV['RUOTE_STORAGE_DB'])
      else
        raise ArgumentError.new("unknown DB: #{ENV['RUOTE_STORAGE_DB'].inspect}")
    end

  require 'logger'

  logger =
    case dbg = ENV['RUOTE_STORAGE_DEBUG']
      when 'log'
        FileUtils.rm("debug_#{$$}.log") rescue nil
        Logger.new("debug_#{$$}.log")
      when 'stdout'
        Logger.new($stdout)
      when /\.(log|txt)$/
        Logger.new(dbg)
      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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ruote-sequel-2.3.0.2 test/connection.rb