X-Git-Url: http://gitweb.michael.orlitzky.com/?p=mailshears.git;a=blobdiff_plain;f=lib%2Fprune%2Fprune_plugin.rb;h=df621b8aeb79644874adc091e9c6081219cc0cd6;hp=2776704a4135b5be897945a6683d4bb24dbe5d61;hb=f52761d8c74b146415329f7a8ac004ced0ab4db8;hpb=e3826d8926e11763837a591986d453e9ef5d9dec diff --git a/lib/prune/prune_plugin.rb b/lib/prune/prune_plugin.rb index 2776704..df621b8 100644 --- a/lib/prune/prune_plugin.rb +++ b/lib/prune/prune_plugin.rb @@ -1,35 +1,66 @@ -require 'rm/rm_plugin' +require 'common/plugin.rb' +# Plugins for pruning users. By "pruning," we mean the removal of +# leftover non-PostfixAdmin users after the associated user has been +# removed from the Postfixadmin database. +# module PrunePlugin - include RmPlugin + # Absorb the subclass run() magic from the Plugin::Run module. + extend Plugin::Run + + # The runner class associated with pruning plugins. # - # Plugins for the removal of leftover non-PostfixAdmin accounts, - # i.e. after an account has been removed from the PostfixAdmin - # database. + # @return [Class] the {PruneRunner} class. # - - def PrunePlugin.included(c) - # Callback, called whenever another class or module includes this - # one. The parameter given is the name of the class or module - # that included us. - @includers ||= [] - @includers << c + def self.runner() + return PruneRunner end - def PrunePlugin.includers - return @includers + + # The "dummy" runner class associated with pruning plugins. + # + # @return [Class] the {PruneDummyRunner} class. + # + def self.dummy_runner + return PruneDummyRunner end + + # Determine which domains are "left over" for this plugin. A domain + # is considered "left over" if it has been removed from Postfixadmin + # but not some other plugin. + # + # The leftovers are determined with respect to the list *db_domains* + # of domains that Postfixadmin knows about. + # + # @param db_domains [Array] a list of domains that are present + # in the Postfixadmin database. + # + # @return [Array] a list of domains known to this plugin but + # not to Postfixadmin. + # 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 + # WARNING! Array difference doesn't work for some reason. + return list_domains().select{ |d| !db_domains.include?(d) } 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 + + # Determine which users are "left over" for this plugin. A user + # is considered "left over" if it has been removed from Postfixadmin + # but not some other plugin. + # + # The leftovers are determined with respect to the list *db_users* + # of users that Postfixadmin knows about. + # + # @param db_users [Array] a list of users that are present + # in the Postfixadmin database. + # + # @return [Array] a list of users known to this plugin but + # not to Postfixadmin. + # + def get_leftover_users(db_users) + # WARNING! Array difference doesn't work for some reason. + return list_users().select{ |u| !db_users.include?(u) } end end