Module: Workit::Model

Defined in:
lib/workit/model.rb,
lib/workit/model/span.rb,
lib/workit/model/task.rb

Defined Under Namespace

Classes: Span, Task

Class Method Summary collapse

Class Method Details

.get_sqlite_dbObject



11
12
13
14
15
16
17
# File 'lib/workit/model.rb', line 11

def self.get_sqlite_db
  if ENV['WORKIT_ENV'] == 'test'
    "/tmp/workit_test.db"
  else
    File.expand_path(File.join(ENV['HOME'], '.workit', 'database.db'))
  end
end

.setupObject



19
20
21
22
23
24
# File 'lib/workit/model.rb', line 19

def self.setup
  FileUtils.mkdir_p(File.dirname(get_sqlite_db))
  DataMapper.setup(:default, "sqlite://#{get_sqlite_db}")
  DataMapper.finalize
  DataMapper.auto_upgrade!
end