Rubernate

{Dynamic Persistence
for Dynamic Language}

# This file contains common configuration for all examples and
# database initialization that runs if this script was executed as stand alone application.

require 'rubernate'
require 'fileutils'

# MySQL configuration
#  * config type   - :mysql
#  * db url        - 'dbi:Mysql:rubernate_db:localhost'
#  * db login      - nil
#  * db password   - nil
Rubernate.config :mysql, 'dbi:Mysql:rubernate_db:localhost', nil, nil  

# Oracle configuration
#Rubernate.config :oracle, 'dbi:OCI8:dbg91', 'login', 'password'


# Initialize database if we run this file
if __FILE__ == $0
  Rubernate.init_db                   
  puts "Database initialized ... \n\n"
end


# Create directory for logs
FileUtils.mkdir 'logs' unless File.exist? 'logs'

# Log4r configuration.
Rubernate::Log.level = Log4r::DEBUG
Rubernate::Log.add Log4r::FileOutputter.new('file',
    :filename => "logs/#{$0}".sub('.rb', '.log'),
    :trunc => true)