Move the Runner selection into the plugin.
authorMichael Orlitzky <michael@orlitzky.com>
Sat, 4 Jan 2014 18:38:29 +0000 (13:38 -0500)
committerMichael Orlitzky <michael@orlitzky.com>
Sat, 4 Jan 2014 18:38:29 +0000 (13:38 -0500)
bin/mailshears
lib/common/plugin.rb
lib/mv/mv_plugin.rb
lib/prune/prune_plugin.rb
lib/rm/rm_dummy_runner.rb
lib/rm/rm_plugin.rb

index f7b1963cc8bde0a49cfc388fa29d963cf8e3db55..1398a8f06ab67d7cb5aac84d1bf2aa2d074953ce 100755 (executable)
@@ -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
index b0b57505873665a856dcf7ade0eafc4b82cf266a..ed4ea004041a8986a151783707ffec1ff939815f 100644 (file)
@@ -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
index 40184422fbd8f9a5601fa3a57a92632163007d47..958f6d40f98d0fd3d3cfdb76d24000c6fcd7b844 100644 (file)
@@ -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
index e47a5e4aafbd6370fcf07aca76e30b8804fa34c0..0fbe69d12f403f7ed12ce8954b425b72b107d6f1 100644 (file)
@@ -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.
index 60cf23ab8b32c12eefd06fce87a659c697689f0d..477608f8e77318e535ef671eca0bb7a629a5d0ad 100644 (file)
@@ -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
 
index fc0e7a081d97f602124dc9ccaef2ba53b60aa1d6..95c595aa2afc94c881007c8984c7fb4b276aa521 100644 (file)
@@ -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