Module: Oughtve::Database

Defined in:
lib/oughtve/database.rb

Constant Summary collapse

Path =

The database file path.

File.expand_path "#{Oughtve::ResourceDirectory}/data.db"
URI =

The full URI to access the DB.

"sqlite3:///#{Path}"

Class Method Summary collapse

Class Method Details

.bootstrapObject

Create a brand-new database.

Raises:



76
77
78
79
# File 'lib/oughtve/database.rb', line 76

def self.bootstrap()
  raise OughtveError, "#{Path} already exists!" if File.exist? Path
  connect and DataMapper.auto_migrate!
end

.connectObject

Connect to database (new or existing)



68
69
70
71
# File 'lib/oughtve/database.rb', line 68

def self.connect()
  DataMapper::Logger.new(STDOUT, :debug) if $VERBOSE
  DataMapper.setup :default, URI
end