lib/ardb.rb in ardb-0.5.0 vs lib/ardb.rb in ardb-0.6.0
- old
+ new
@@ -4,10 +4,12 @@
require 'ns-options'
require 'ardb/version'
require 'ardb/root_path'
+ENV['ARDB_DB_FILE'] ||= 'config/db'
+
module Ardb
NotConfiguredError = Class.new(RuntimeError)
def self.config; Config; end
def self.configure(&block); Config.define(&block); end
@@ -19,10 +21,11 @@
raise NotConfiguredError, "missing required configs"
end
end
def self.init(establish_connection=true)
+ require self.config.db_file
validate!
Adapter.init
# setup AR
ActiveRecord::Base.logger = self.config.logger
@@ -42,9 +45,10 @@
option :port, Integer, :required => false
option :username, String, :required => false
option :password, String, :required => false
end
+ option :db_file, Pathname, :default => ENV['ARDB_DB_FILE']
option :root_path, Pathname, :required => true
option :logger, :required => true
option :migrations_path, RootPath, :default => proc{ "db/migrations" }
option :schema_path, RootPath, :default => proc{ "db/schema.rb" }