summaryrefslogtreecommitdiff
path: root/lib/tapicero.rb
blob: 3923c65f4f13722a505bdd225d59bf34e6ed0455 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
unless defined? BASE_DIR
  BASE_DIR = Pathname.new(__FILE__) + '../..'
end
unless defined? TAPICERO_CONFIG
  TAPICERO_CONFIG = '/etc/leap/tapicero.yaml'
end

module Tapicero
  class <<self
    attr_accessor :logger
    attr_accessor :config
  end


  #
  # Load Config
  # this must come first, because CouchRest needs the connection
  # defined before the models are defined.
  #
  require 'couchrest/changes'
  configs = ['config/default.yaml', TAPICERO_CONFIG, ARGV.grep(/\.ya?ml$/).first]
  self.config = CouchRest::Changes::Config.load(BASE_DIR, *configs)
  self.logger = CouchRest::Changes::Config.logger

  #
  # Load Tapicero Parts
  #
  require 'tapicero/user_database'

  def self.user_database(id)
    UserDatabase.new(config.couch_host, config.options[:db_prefix] + id)
  end
end