module Takana

Public Class Methods

db() click to toggle source
# File lib/rack-takana.rb, line 23
def self.db
  @db
end
initialize_db() click to toggle source
# File lib/rack-takana.rb, line 17
def self.initialize_db
  @db = Sequel.connect("sqlite://#{URI.escape(Takana.sqlite_filepath)}") rescue nil

  Sequel::Model.db = @db
end
migrate!() click to toggle source
# File lib/rack-takana.rb, line 27
def self.migrate!
  Sequel.extension :migration

  Sequel::Migrator.run(Takana.db, File.expand_path("../sassy_bunny/app/db/migrations").to_s, use_transactions: true)
end
sqlite_filepath() click to toggle source
# File lib/rack-takana.rb, line 8
def self.sqlite_filepath
  if ENV['TAKANA_ENV'] == "test"
    File.expand_path("./test.db")
  else
    Pathname.new( File.expand_path("~") ).
      join("Library", "Application Support", "Edge", "takana.db").to_s
  end
end