]> gitweb.michael.orlitzky.com - mailshears.git/blob - lib/common/configuration.rb
Update the supported version of Roundcube.
[mailshears.git] / lib / common / configuration.rb
1 require 'yaml'
2
3 class Configuration
4
5 USERCONF_PATH = ENV['HOME'] + '/.mailshears.conf.yml'
6 @dict = {}
7
8 def initialize(path = USERCONF_PATH)
9 cfg = default_configuration()
10
11 # Now, load the user configuration which will override the
12 # variables defined above.
13 begin
14 user_config = YAML.load(File.open(path))
15
16 # Write our own update() method for Ruby 1.8.
17 user_config.each do |key, value|
18 cfg[key] = value
19 end
20 rescue Errno::ENOENT
21 # If the user config file doesn't exist, whatever.
22 end
23
24 # Convert all of the keys to symbols.
25 cfg = cfg.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
26
27 @dict = cfg
28 end
29
30
31 def method_missing(sym, *args)
32 # Replace all missing method calls with dictionary lookups.
33 return @dict[sym]
34 end
35
36
37 private;
38
39 def default_configuration()
40 d = {}
41
42 d['i_mean_business'] = false
43
44 d['postfixadmin_dbhost'] = 'localhost'
45 d['postfixadmin_dbport'] = 5432
46 d['postfixadmin_dbopts'] = ''
47 d['postfixadmin_dbtty'] = ''
48 d['postfixadmin_dbuser'] = 'postgres'
49 d['postfixadmin_dbpass'] = ''
50 d['postfixadmin_dbname'] = 'postfixadmin'
51
52 d['plugins'] = ['postfixadmin',
53 'dovecot',
54 'roundcube',
55 'agendav',
56 'davical']
57
58 d['mail_root'] = '/var/spool/mail/vhosts'
59
60 d['roundcube_dbhost'] = 'localhost'
61 d['roundcube_dbport'] = 5432
62 d['roundcube_dbopts'] = ''
63 d['roundcube_dbtty'] = ''
64 d['roundcube_dbuser'] = 'postgres'
65 d['roundcube_dbpass'] = ''
66 d['roundcube_dbname'] = 'roundcube'
67
68 d['agendav_dbhost'] = 'localhost'
69 d['agendav_dbport'] = 5432
70 d['agendav_dbopts'] = ''
71 d['agendav_dbtty'] = ''
72 d['agendav_dbuser'] = 'postgres'
73 d['agendav_dbpass'] = ''
74 d['agendav_dbname'] = 'agendav'
75
76 d['davical_dbhost'] = 'localhost'
77 d['davical_dbport'] = 5432
78 d['davical_dbopts'] = ''
79 d['davical_dbtty'] = ''
80 d['davical_dbuser'] = 'postgres'
81 d['davical_dbpass'] = ''
82 d['davical_dbname'] = 'davical'
83
84 return d
85 end
86
87 end