From: Michael Orlitzky Date: Thu, 19 Apr 2012 13:55:59 +0000 (-0400) Subject: Update the rest of the code to use the new Configuration class. X-Git-Tag: 0.0.1~109 X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=a4db2e7eaaf9d17f9250d601bf82b58bdb2681d2;p=mailshears.git Update the rest of the code to use the new Configuration class. --- diff --git a/bin/mailshears b/bin/mailshears index b1a5e00..d181d08 100755 --- a/bin/mailshears +++ b/bin/mailshears @@ -15,13 +15,14 @@ require 'mailshears' -pgadb = PostfixadminDb.new(Configuration::dbhost, - Configuration::dbport, - Configuration::dbopts, - Configuration::dbtty, - Configuration::dbname, - Configuration::dbuser, - Configuration::dbpass) +cfg = Configuration.new() +pgadb = PostfixadminDb.new(cfg.dbhost, + cfg.dbport, + cfg.dbopts, + cfg.dbtty, + cfg.dbname, + cfg.dbuser, + cfg.dbpass) begin @@ -84,7 +85,7 @@ Plugin.includers.each do |plugin_class| puts "Found: #{account} (#{plugin.describe_account(account)})" end - if Configuration::i_mean_business + if cfg.i_mean_business # We have to delete the accounts before the domain, # otherwise they'd already be gone. leftover_accounts.each do |account| diff --git a/lib/mailshears.rb b/lib/mailshears.rb index e159b09..f4e75f7 100644 --- a/lib/mailshears.rb +++ b/lib/mailshears.rb @@ -1,21 +1,13 @@ # Load the rest of the code we'll use. # And the necessary classes. -require 'mailshears/errors.rb' -require 'mailshears/exit_codes.rb' +require 'mailshears/configuration' +require 'mailshears/errors' +require 'mailshears/exit_codes' require 'mailshears/postfixadmin_db' -# Load the default config file first, and let the user override it. -require 'default_configuration' +cfg = Configuration.new() -userconf_path = ENV['HOME'] + '/.mailshears.conf.rb' -begin - # Don't crash if it doesn't exist. Maybe he likes the defaults? - require userconf_path -rescue LoadError -end - -Configuration::plugins.each do |plugin_file| +Configuration.plugins.each do |plugin_file| require "mailshears/plugins/#{plugin_file}" end - diff --git a/lib/mailshears/plugins/dovecot_mailstore.rb b/lib/mailshears/plugins/dovecot_mailstore.rb index 965d2d2..44701bb 100644 --- a/lib/mailshears/plugins/dovecot_mailstore.rb +++ b/lib/mailshears/plugins/dovecot_mailstore.rb @@ -1,6 +1,7 @@ # Needed for rm_rf. require 'fileutils' +require 'mailshears/configuration' require 'mailshears/errors' require 'mailshears/filesystem' require 'mailshears/mailstore' @@ -11,7 +12,8 @@ class DovecotMailstore < Mailstore include Plugin def initialize - @domain_root = Configuration::mail_root + cfg = Configuration.new() + @domain_root = cfg.mail_root end def describe_domain(domain) diff --git a/lib/mailshears/plugins/roundcube_db.rb b/lib/mailshears/plugins/roundcube_db.rb index c86d314..111e360 100644 --- a/lib/mailshears/plugins/roundcube_db.rb +++ b/lib/mailshears/plugins/roundcube_db.rb @@ -5,13 +5,14 @@ class RoundcubeDb include Plugin def initialize() - @db_host = Configuration::roundcube_dbhost - @db_port = Configuration::roundcube_dbport - @db_opts = Configuration::roundcube_dbopts - @db_tty = Configuration::roundcube_dbtty - @db_name = Configuration::roundcube_dbname - @db_user = Configuration::roundcube_dbuser - @db_pass = Configuration::roundcube_dbpass + cfg = Configuration.new() + @db_host = cfg.roundcube_dbhost + @db_port = cfg.roundcube_dbport + @db_opts = cfg.roundcube_dbopts + @db_tty = cfg.roundcube_dbtty + @db_name = cfg.roundcube_dbname + @db_user = cfg.roundcube_dbuser + @db_pass = cfg.roundcube_dbpass end