Update the rest of the code to use the new Configuration class.
authorMichael Orlitzky <michael@orlitzky.com>
Thu, 19 Apr 2012 13:55:59 +0000 (09:55 -0400)
committerMichael Orlitzky <michael@orlitzky.com>
Thu, 19 Apr 2012 13:55:59 +0000 (09:55 -0400)
bin/mailshears
lib/mailshears.rb
lib/mailshears/plugins/dovecot_mailstore.rb
lib/mailshears/plugins/roundcube_db.rb

index b1a5e00e1d66885f7ceed478f6031912b540429f..d181d0834f70a84492530a779a6b022c9ee2c674 100755 (executable)
 
 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|
index e159b09b3b6ca6c93dce474a1d0106b1ae261b42..f4e75f7e3069a6c21a28b5bc20ca3f836a94f98b 100644 (file)
@@ -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
-
index 965d2d293a5047252287ea1722f8e7c40278fc58..44701bbd5c21c92c6a53cea72c501347414c9e54 100644 (file)
@@ -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)
index c86d31460e93d96395d4cc29e0849f9a15803ae0..111e360809e25242f81f00bda3bb91be0652ece0 100644 (file)
@@ -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