X-Git-Url: http://gitweb.michael.orlitzky.com/?p=mailshears.git;a=blobdiff_plain;f=lib%2Fcommon%2Fconfiguration.rb;h=02c30d252b796073587ee961011a02ccbebb1936;hp=b810b02f86c9d44711fbdae7836c391035d72c80;hb=HEAD;hpb=df4e02ebf6a4e28a58abcb298a4442a245ad0b15 diff --git a/lib/common/configuration.rb b/lib/common/configuration.rb index b810b02..78f5c04 100644 --- a/lib/common/configuration.rb +++ b/lib/common/configuration.rb @@ -1,9 +1,9 @@ require 'yaml' # A configuration object that knows how to read options out of a file -# in ~/.mailshears.conf.yml. The configuration options can be -# accessed via methods even though the internal representation is a -# hash. +# in $XDG_CONFIG_HOME/mailshears/mailshears.conf.yml. The +# configuration options can be accessed via methods even though the +# internal representation is a hash. # # === Examples # @@ -13,21 +13,26 @@ require 'yaml' # class Configuration - # The default path to the user's configuration file. - USERCONF_PATH = ENV['HOME'] + '/.mailshears.conf.yml' - # The hash structure in which we store our configuration options # internally. @dict = {} - # Initialize a {Configuration} object with the config file at *path*. # # @param path [String] the path to the configuration file to - # load. We check for a file named ".mailshears.conf.yml" in the - # user's home directory by default. + # load. We check for a file named "mailshears.conf.yml" in the + # user's XDG configuration directory by default. # - def initialize(path = USERCONF_PATH) + def initialize(path = nil) + if path.nil? then + # The default path to the user's configuration file. + path = ENV['HOME'] + '/.config' + if ENV.has_key?('XDG_CONFIG_HOME') then + path = ENV['XDG_CONFIG_HOME'] + end + path += '/mailshears/mailshears.conf.yml' + end + cfg = default_configuration() # Now, load the user configuration which will override the @@ -74,34 +79,20 @@ class Configuration d = {} d['i_mean_business'] = false - d['plugins'] = ['agendav', - 'davical', - 'dovecot', - 'postfixadmin', - 'roundcube'] - - d['agendav_dbhost'] = 'localhost' - d['agendav_dbport'] = 5432 - d['agendav_dbopts'] = '' - d['agendav_dbtty'] = '' - d['agendav_dbuser'] = 'postgres' - d['agendav_dbpass'] = '' - d['agendav_dbname'] = 'agendav' + d['plugins'] = ['postfixadmin'] d['davical_dbhost'] = 'localhost' d['davical_dbport'] = 5432 d['davical_dbopts'] = '' - d['davical_dbtty'] = '' d['davical_dbuser'] = 'postgres' d['davical_dbpass'] = '' d['davical_dbname'] = 'davical' - d['dovecot_mail_root'] = '/var/spool/mail/vhosts' + d['dovecot_mail_root'] = '/tmp/mailshears-test' d['postfixadmin_dbhost'] = 'localhost' d['postfixadmin_dbport'] = 5432 d['postfixadmin_dbopts'] = '' - d['postfixadmin_dbtty'] = '' d['postfixadmin_dbuser'] = 'postgres' d['postfixadmin_dbpass'] = '' d['postfixadmin_dbname'] = 'postfixadmin' @@ -109,7 +100,6 @@ class Configuration d['roundcube_dbhost'] = 'localhost' d['roundcube_dbport'] = 5432 d['roundcube_dbopts'] = '' - d['roundcube_dbtty'] = '' d['roundcube_dbuser'] = 'postgres' d['roundcube_dbpass'] = '' d['roundcube_dbname'] = 'roundcube'