From: Michael Orlitzky Date: Tue, 19 Mar 2013 18:38:35 +0000 (-0400) Subject: Factor out common code that can be used to mv (rename) accounts. X-Git-Tag: 0.0.1~92 X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=c6cab6b71770d14dad1115db90a00b990c44a58d;p=mailshears.git Factor out common code that can be used to mv (rename) accounts. Separate Plugin/RmPlugin modules. --- diff --git a/lib/mailshears/configuration.rb b/lib/common/configuration.rb similarity index 100% rename from lib/mailshears/configuration.rb rename to lib/common/configuration.rb diff --git a/lib/mailshears/errors.rb b/lib/common/errors.rb similarity index 100% rename from lib/mailshears/errors.rb rename to lib/common/errors.rb diff --git a/lib/mailshears/exit_codes.rb b/lib/common/exit_codes.rb similarity index 100% rename from lib/mailshears/exit_codes.rb rename to lib/common/exit_codes.rb diff --git a/lib/mailshears/filesystem.rb b/lib/common/filesystem.rb similarity index 100% rename from lib/mailshears/filesystem.rb rename to lib/common/filesystem.rb diff --git a/lib/mailshears/mailstore.rb b/lib/common/mailstore.rb similarity index 100% rename from lib/mailshears/mailstore.rb rename to lib/common/mailstore.rb diff --git a/lib/mailshears/plugin.rb b/lib/common/plugin.rb similarity index 59% rename from lib/mailshears/plugin.rb rename to lib/common/plugin.rb index 2e868c2..0687989 100644 --- a/lib/mailshears/plugin.rb +++ b/lib/common/plugin.rb @@ -28,25 +28,4 @@ module Plugin raise NotImplementedError end - def delete_domain(domain) - # Delete the given domain. - raise NotImplementedError - end - - def delete_account(account) - # Delete the given account. - raise NotImplementedError - end - - def get_leftover_domains(db_domains) - # Given a list of domains, determine which domains belonging to - # this plugin are not contained in the given list. - raise NotImplementedError - end - - def get_leftover_accounts(db_accounts) - # Given a list of accounts, determine which accounts belonging to - # this plugin are not contained in the given list. - raise NotImplementedError - end end diff --git a/lib/mailshears.rb b/lib/mailshears.rb index 287ee2b..cb8e43c 100644 --- a/lib/mailshears.rb +++ b/lib/mailshears.rb @@ -1,9 +1,10 @@ -# Load the rest of the code we'll use. +# Load the rest of the code we'll use. This loads what we'll need in +# the executables; the library files are supposed to require what they +# need. -# And the necessary classes. -require 'mailshears/configuration' -require 'mailshears/errors' -require 'mailshears/exit_codes' +require 'common/configuration' +require 'common/errors' +require 'common/exit_codes' require 'mailshears/postfixadmin_db' cfg = Configuration.new() diff --git a/lib/mailshears/plugins/agendav.rb b/lib/mailshears/plugins/agendav.rb index 9746f1c..3578302 100644 --- a/lib/mailshears/plugins/agendav.rb +++ b/lib/mailshears/plugins/agendav.rb @@ -1,8 +1,12 @@ require 'pg' +require 'common/plugin' +require 'mailshears/rm_plugin' + class AgendavDb include Plugin + include RmPlugin def initialize() cfg = Configuration.new() diff --git a/lib/mailshears/plugins/davical.rb b/lib/mailshears/plugins/davical.rb index 0c63ee2..2091529 100644 --- a/lib/mailshears/plugins/davical.rb +++ b/lib/mailshears/plugins/davical.rb @@ -1,11 +1,15 @@ require 'pg' +require 'common/plugin' +require 'mailshears/rm_plugin' + class DavicalDb # # DAViCal only supports Postgres, so even if we ever are # database-agnostic, this plugin can't be. # include Plugin + include RmPlugin def initialize() cfg = Configuration.new() diff --git a/lib/mailshears/plugins/dovecot_mailstore.rb b/lib/mailshears/plugins/dovecot_mailstore.rb index cf4711c..635d6ef 100644 --- a/lib/mailshears/plugins/dovecot_mailstore.rb +++ b/lib/mailshears/plugins/dovecot_mailstore.rb @@ -1,15 +1,15 @@ # Needed for rm_rf. require 'fileutils' -require 'mailshears/configuration' -require 'mailshears/errors' -require 'mailshears/filesystem' -require 'mailshears/mailstore' -require 'mailshears/plugin' +require 'common/filesystem' +require 'common/mailstore' +require 'common/plugin' +require 'mailshears/rm_plugin' class DovecotMailstore < Mailstore include Plugin + include RmPlugin def initialize cfg = Configuration.new() diff --git a/lib/mailshears/plugins/roundcube_db.rb b/lib/mailshears/plugins/roundcube_db.rb index 7d1a037..a930189 100644 --- a/lib/mailshears/plugins/roundcube_db.rb +++ b/lib/mailshears/plugins/roundcube_db.rb @@ -1,8 +1,12 @@ require 'pg' +require 'common/plugin' +require 'mailshears/rm_plugin' + class RoundcubeDb include Plugin + include RmPlugin def initialize() cfg = Configuration.new() diff --git a/lib/mailshears/rm_plugin.rb b/lib/mailshears/rm_plugin.rb new file mode 100644 index 0000000..0c155a1 --- /dev/null +++ b/lib/mailshears/rm_plugin.rb @@ -0,0 +1,27 @@ +module RmPlugin + # + # Plugins for the removal of accounts. + # + + def delete_domain(domain) + # Delete the given domain. + raise NotImplementedError + end + + def delete_account(account) + # Delete the given account. + raise NotImplementedError + end + + def get_leftover_domains(db_domains) + # Given a list of domains, determine which domains belonging to + # this plugin are not contained in the given list. + raise NotImplementedError + end + + def get_leftover_accounts(db_accounts) + # Given a list of accounts, determine which accounts belonging to + # this plugin are not contained in the given list. + raise NotImplementedError + end +end