From: Michael Orlitzky Date: Sat, 4 Jan 2014 18:38:29 +0000 (-0500) Subject: Move the Runner selection into the plugin. X-Git-Tag: 0.0.1~70 X-Git-Url: http://gitweb.michael.orlitzky.com/?p=mailshears.git;a=commitdiff_plain;h=6f2bc0181c6bb900e37d04ea722beec54486b87e Move the Runner selection into the plugin. --- diff --git a/bin/mailshears b/bin/mailshears index f7b1963..1398a8f 100755 --- a/bin/mailshears +++ b/bin/mailshears @@ -84,22 +84,14 @@ end plugin_class = nil -runner_class = nil -dummy_runner_class = nil if mode == :rm then plugin_class = RmPlugin - runner_class = RmRunner - dummy_runner_class = RmDummyRunner elsif mode == :mv then plugin_class = MvPlugin - runner_class = MvRunner - dummy_runner_class = MvDummyRunner else # Safe, catch-all default plugin_class = PrunePlugin - runner_class = PruneRunner - dummy_runner_class = PruneDummyRunner end @@ -113,9 +105,9 @@ plugin_class.includers.each do |plugin_class_includer| plugin = plugin_class_includer.new(cfg) if cfg.i_mean_business then - runner = runner_class.new() + runner = plugin.runner().new() else - runner = dummy_runner_class.new() + runner = plugin.dummy_runner().new() end # The splat passes the correct (we hope) number of arguments to the diff --git a/lib/common/plugin.rb b/lib/common/plugin.rb index b0b5750..ed4ea00 100644 --- a/lib/common/plugin.rb +++ b/lib/common/plugin.rb @@ -14,6 +14,16 @@ module Plugin return @includers end + def runner() + # The Runner associated with this plugin. + raise NotImplementedError + end + + def dummy_runner() + # The RummyRunner associated with this plugin. + raise NotImplementedError + end + def describe_domain(domain) # Provide a "description" of the domain. This is output along # with the domain name and can be anything of use to the system diff --git a/lib/mv/mv_plugin.rb b/lib/mv/mv_plugin.rb index 4018442..958f6d4 100644 --- a/lib/mv/mv_plugin.rb +++ b/lib/mv/mv_plugin.rb @@ -15,6 +15,14 @@ module MvPlugin return @includers end + def runner() + return MvRunner + end + + def dummy_runner() + return MvDummyRunner + end + def mv_domain(from, to) # Rename the given domain. raise NotImplementedError diff --git a/lib/prune/prune_plugin.rb b/lib/prune/prune_plugin.rb index e47a5e4..0fbe69d 100644 --- a/lib/prune/prune_plugin.rb +++ b/lib/prune/prune_plugin.rb @@ -21,6 +21,14 @@ module PrunePlugin return @includers end + def runner() + return PruneRunner + end + + def dummy_runner + return PruneDummyRunner + 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. diff --git a/lib/rm/rm_dummy_runner.rb b/lib/rm/rm_dummy_runner.rb index 60cf23a..477608f 100644 --- a/lib/rm/rm_dummy_runner.rb +++ b/lib/rm/rm_dummy_runner.rb @@ -7,10 +7,10 @@ class RmDummyRunner targets.each do |target| if target.include?('@') then user_description = plugin.describe_user(target) - report(plugin, "Would remove user: #{user} (#{user_description})") + report(plugin, "Would remove user: #{target} (#{user_description})") else domain_description = plugin.describe_domain(target) - report(plugin, "Would remove domain: #{domain} (#{domain_description})") + report(plugin, "Would remove domain: #{target} (#{domain_description})") end end diff --git a/lib/rm/rm_plugin.rb b/lib/rm/rm_plugin.rb index fc0e7a0..95c595a 100644 --- a/lib/rm/rm_plugin.rb +++ b/lib/rm/rm_plugin.rb @@ -15,6 +15,14 @@ module RmPlugin return @includers end + def runner() + return RmRunner + end + + def dummy_runner() + return RmDummyRunner + end + def delete_domain(domain) # Delete the given domain. Some plugins don't have a concept of # domains, so just delete all users with a username that looks