X-Git-Url: http://gitweb.michael.orlitzky.com/?p=mailshears.git;a=blobdiff_plain;f=lib%2Frm%2Frm_dummy_runner.rb;h=54a8969bcc6925d5c55590b0a537e2367a66846d;hp=9bdd13f5f47fb2dc1b71e7c012545c47c08e7e4a;hb=df4e02ebf6a4e28a58abcb298a4442a245ad0b15;hpb=51f027b01e242737956c3ab5aecdd322d6ceeeed
diff --git a/lib/rm/rm_dummy_runner.rb b/lib/rm/rm_dummy_runner.rb
index 9bdd13f..54a8969 100644
--- a/lib/rm/rm_dummy_runner.rb
+++ b/lib/rm/rm_dummy_runner.rb
@@ -1,20 +1,43 @@
require 'common/runner'
+# Dummy implementation of a {RmRunner}. Its run() method will
+# tell you what would have been removed, but will not actually perform
+# the operation.
+#
class RmDummyRunner
include Runner
- def run(plugin, *targets)
+
+ # Pretend to remove *targets*. Some "what if"
+ # information will be output to stdout.
+ #
+ # This dummy runner is not particularly useful on its own. About the
+ # only thing it does is let you know that the users/domains in
+ # *targets* do in fact exist (through their descriptions). It's used
+ # to good effect by {PruneDummyRunner}, though.
+ #
+ # @param cfg [Configuration] the configuration options to pass to
+ # the *plugin* we're runnning.
+ #
+ # @param plugin [RmPlugin] plugin that will perform the move.
+ #
+ # @param targets [Array] the users and domains to be
+ # removed.
+ #
+ def run(cfg, plugin, *targets)
targets.each do |target|
- if target.include?('@') then
- puts "Would remove account: #{target}"
- # TODO: remove from postfixadmin as well.
- else
- usernames = plugin.get_domain_usernames(target)
- usernames.each { |u| run(plugin, u) }
+ target_description = plugin.describe(target)
+ msg = "Would remove #{target.class.to_s().downcase()} #{target}"
- puts "Would remove domain: #{target}"
- # TODO: remove from postfixadmin as well.
+ # Only append the extra description if it's useful.
+ if not target_description.nil? and
+ not target_description.empty? and
+ not target_description == target.to_s() then
+ msg += " (#{target_description})"
end
+ msg += '.'
+
+ report(plugin, msg)
end
end