lib,test: replace connection query() method with sync_exec{,_params}.
[mailshears.git] / lib / mv / mv_dummy_runner.rb
1 require 'common/runner'
2
3 # Dummy implementation of a {MvRunner}. Its <tt>run()</tt> method will
4 # tell you what would have been moved, but will not actually perform
5 # the operation.
6 #
7 class MvDummyRunner
8 include Runner
9
10 # Pretend to move *src* to *dst* with *plugin*. Some "what if"
11 # information will be output to stdout. This is useful to see if
12 # there would be (for example) a username collision at *dst* before
13 # attempting the move in earnest.
14 #
15 # @param cfg [Configuration] the configuration options to pass to
16 # the *plugin* we're runnning.
17 #
18 # @param plugin [Class] plugin class that will perform the move.
19 #
20 # @param src [User] the source user to be moved.
21 #
22 # @param dst [User] the destination user, to which we will move *src*.
23 #
24 def run(cfg, plugin, src, dst)
25
26 if src.is_a?(Domain) or dst.is_a?(Domain) then
27 msg = 'only users can be moved'
28 raise NotImplementedError.new(msg)
29 end
30
31 # Since we're not actually moving anything, the destination
32 # description is really only useful for seeing whether or not we'd
33 # be trying to move in on top of an existing account.
34 src_description = plugin.describe(src)
35 dst_description = plugin.describe(dst)
36
37 msg = "Would move user "
38 msg += add_description(src, src_description)
39 msg += " to "
40 add_description(dst, dst_description)
41 msg += "."
42 report(plugin, msg)
43 end
44
45 end