Switch from constants to variables in the Configuration module. This should keep...
authorMichael Orlitzky <michael@orlitzky.com>
Thu, 19 Apr 2012 12:54:01 +0000 (08:54 -0400)
committerMichael Orlitzky <michael@orlitzky.com>
Thu, 19 Apr 2012 12:54:01 +0000 (08:54 -0400)
Change the local config path from $HOME/.mailshears.conf to $HOME/.mailshears.conf.rb so that Ruby will actually load it.

README
bin/mailshears
lib/default_configuration.rb
lib/mailshears.rb
lib/mailshears/plugins/dovecot_mailstore.rb
lib/mailshears/plugins/roundcube_db.rb

diff --git a/README b/README
index 77ad551005ebb5fd1d424c2f79f276ee98defa57..1fd643ce9e8fddcfb3a5f70b238d30496214d5b7 100644 (file)
--- a/README
+++ b/README
@@ -36,7 +36,7 @@ Right now, mailshears is targeted at one type of setup:
 You put it in a directory somewhere, and run bin/mailshears. To make
 it do anything, you'll need to create a config file. The default is
 stored in lib/default_configuration.rb; I suggest you copy that to
-$HOME/.mailshears.conf and edit it to fit your environment.
+$HOME/.mailshears.conf.rb and edit it to fit your environment.
 
 You'll probably want to set up a cron job to run it every once in a
 while.
index 01dcb30f2a2fc2d73d22f36f2f4b43ed92800f42..b1a5e00e1d66885f7ceed478f6031912b540429f 100755 (executable)
 
 require 'mailshears'
 
-pgadb = PostfixadminDb.new(Configuration::DBHOST,
-                           Configuration::DBPORT,
-                           Configuration::DBOPTS,
-                           Configuration::DBTTY,
-                           Configuration::DBNAME,
-                           Configuration::DBUSER,
-                           Configuration::DBPASS)
+pgadb = PostfixadminDb.new(Configuration::dbhost,
+                           Configuration::dbport,
+                           Configuration::dbopts,
+                           Configuration::dbtty,
+                           Configuration::dbname,
+                           Configuration::dbuser,
+                           Configuration::dbpass)
 
 
 begin
@@ -84,7 +84,7 @@ Plugin.includers.each do |plugin_class|
       puts "Found: #{account} (#{plugin.describe_account(account)})"
     end
 
-    if Configuration::I_MEAN_BUSINESS
+    if Configuration::i_mean_business
       # We have to delete the accounts before the domain,
       # otherwise they'd already be gone.
       leftover_accounts.each do |account|
index 7f3b8920998280cb3b73df4bb0093148793f6d78..fa20472a76cc53fa629cb57c26ce74a07929336c 100644 (file)
@@ -1,38 +1,38 @@
 module Configuration
   # Really delete domains/accounts, or just find them? This parameter
-  # could also be called, "I_TRUST_MAILSHEARS_NOT_TO_DO_ANYTHING_BAD".
-  I_MEAN_BUSINESS = false
+  # could also be called, "i_trust_mailshears_not_to_do_anything_bad".
+  i_mean_business = false
 
   # How to connect to your user/domain database. At the moment, this
   # is PostfixAdmin.
   #
   # These should be obvious except for the ones that aren't. You can
   # identify the non-obvious ones by my having left them blank.
-  DBHOST = 'localhost'
-  DBPORT = 5432
-  DBOPTS = ''
-  DBTTY = ''
-  DBUSER = 'postgres'
-  DBPASS = ''
-  DBNAME = 'postfix'
+  dbhost = 'localhost'
+  dbport = 5432
+  dbopts = ''
+  dbtty = ''
+  dbuser = 'postgres'
+  dbpass = ''
+  dbname = 'postfix'
 
   # This defines which plugins we'll use. The rest of the
   # configuration is plugin-specific.
-  PLUGINS = ['dovecot_mailstore', 'roundcube_db']
+  plugins = ['dovecot_mailstore', 'roundcube_db']
 
   # Where your mailboxes are stored. The exact format could
   # theoretically change in the future, but for now, the
   # DovecotMailstore class is going to assume that the mailboxes are
   # stored beneath this directory in <domain>/<username> format.
-  MAIL_ROOT = '/var/spool/mail/vhosts'
+  mail_root = '/var/spool/mail/vhosts'
 
   # Roundcube-specific configuration.
-  ROUNDCUBE_DBHOST = 'localhost'
-  ROUNDCUBE_DBPORT = 5432
-  ROUNDCUBE_DBOPTS = ''
-  ROUNDCUBE_DBTTY = ''
-  ROUNDCUBE_DBUSER = 'postgres'
-  ROUNDCUBE_DBPASS = ''
-  ROUNDCUBE_DBNAME = 'roundcube'
+  roundcube_dbhost = 'localhost'
+  roundcube_dbport = 5432
+  roundcube_dbopts = ''
+  roundcube_dbtty = ''
+  roundcube_dbuser = 'postgres'
+  roundcube_dbpass = ''
+  roundcube_dbname = 'roundcube'
 
 end
index 0402d602be047da95203f6fab5391bb2850a1171..e159b09b3b6ca6c93dce474a1d0106b1ae261b42 100644 (file)
@@ -8,14 +8,14 @@ require 'mailshears/postfixadmin_db'
 # Load the default config file first, and let the user override it.
 require 'default_configuration'
 
-userconf_path = ENV['HOME'] + '/.mailshears.conf'
+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 c50b1173050fc81ac100ae4954eafe578fa08e21..965d2d293a5047252287ea1722f8e7c40278fc58 100644 (file)
@@ -11,7 +11,7 @@ class DovecotMailstore < Mailstore
   include Plugin
 
   def initialize
-    @domain_root = Configuration::MAIL_ROOT
+    @domain_root = Configuration::mail_root
   end
 
   def describe_domain(domain)
index cb2e055f44f9b720ca436a510e6f7c0fb85bfadf..c86d31460e93d96395d4cc29e0849f9a15803ae0 100644 (file)
@@ -5,13 +5,13 @@ 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
+    @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
   end