Skip to content

Commit

Permalink
change: moved configuration to Tickets::Config namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
yhara committed Apr 14, 2009
1 parent 69767c9 commit f8dcf33
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
12 changes: 8 additions & 4 deletions bin/tickets-server
Expand Up @@ -3,11 +3,15 @@ require 'rubygems'
require 'ramaze'

# load config
CONF_PATH = File.expand_path("~/.tickets.conf")
if File.exist?(CONF_PATH)
load CONF_PATH
conf_path = File.expand_path("~/.tickets.conf")
load conf_path if File.exist?(conf_path)

# update config
module Tickets
module Config
DB_PATH = File.expand_path("~/.tickets.db") unless defined?(DB_PATH)
end
end
DB_PATH = File.expand_path("~/.tickets.db") unless defined?(DB_PATH)

# connect database
$LOAD_PATH.unshift(File.expand_path("../", File.dirname(__FILE__)))
Expand Down
9 changes: 7 additions & 2 deletions dot.tickets.conf.sample
@@ -1,3 +1,8 @@
#
# ~/.tickets.conf example

DB_PATH = "~/data/tickets.db"
#
module Tickets
module Config
DB_PATH = File.expand_path("~/data/.tickets.db")
end
end
2 changes: 1 addition & 1 deletion model/ticket.rb
Expand Up @@ -2,7 +2,7 @@
require 'sequel/extensions/migration'
Sequel::Model.plugin(:schema) # for table_exists?

$db = Sequel.sqlite(DB_PATH)
$db = Sequel.sqlite(Tickets::Config::DB_PATH)

class Ticket < Sequel::Model(:tickets)

Expand Down

0 comments on commit f8dcf33

Please sign in to comment.