54a8969bcc6925d5c55590b0a537e2367a66846d
[mailshears.git] / lib / rm / rm_dummy_runner.rb
1 require 'common/runner'
2
3 # Dummy implementation of a {RmRunner}. Its <tt>run()</tt> method will
4 # tell you what would have been removed, but will not actually perform
5 # the operation.
6 #
7 class RmDummyRunner
8 include Runner
9
10
11 # Pretend to remove *targets*. Some "what if"
12 # information will be output to stdout.
13 #
14 # This dummy runner is not particularly useful on its own. About the
15 # only thing it does is let you know that the users/domains in
16 # *targets* do in fact exist (through their descriptions). It's used
17 # to good effect by {PruneDummyRunner}, though.
18 #
19 # @param cfg [Configuration] the configuration options to pass to
20 # the *plugin* we're runnning.
21 #
22 # @param plugin [RmPlugin] plugin that will perform the move.
23 #
24 # @param targets [Array<User,Domain>] the users and domains to be
25 # removed.
26 #
27 def run(cfg, plugin, *targets)
28 targets.each do |target|
29 target_description = plugin.describe(target)
30 msg = "Would remove #{target.class.to_s().downcase()} #{target}"
31
32 # Only append the extra description if it's useful.
33 if not target_description.nil? and
34 not target_description.empty? and
35 not target_description == target.to_s() then
36 msg += " (#{target_description})"
37 end
38 msg += '.'
39
40 report(plugin, msg)
41 end
42
43 end
44
45 end