]> gitweb.michael.orlitzky.com - mailshears.git/blobdiff - lib/mv/mv_dummy_runner.rb
lib,test: replace connection query() method with sync_exec{,_params}.
[mailshears.git] / lib / mv / mv_dummy_runner.rb
index 52db27be6f0082051ee17565c7ee7b8b5c61b31a..f73066967d3f42d41e6c3921b48a0b960ce1de8c 100644 (file)
@@ -1,9 +1,27 @@
 require 'common/runner'
 
+# Dummy implementation of a {MvRunner}. Its <tt>run()</tt> method will
+# tell you what would have been moved, but will not actually perform
+# the operation.
+#
 class MvDummyRunner
   include Runner
 
-  def run(plugin, src, dst)
+  # Pretend to move *src* to *dst* with *plugin*. Some "what if"
+  # information will be output to stdout. This is useful to see if
+  # there would be (for example) a username collision at *dst* before
+  # attempting the move in earnest.
+  #
+  # @param cfg [Configuration] the configuration options to pass to
+  #   the *plugin* we're runnning.
+  #
+  # @param plugin [Class] plugin class that will perform the move.
+  #
+  # @param src [User] the source user to be moved.
+  #
+  # @param dst [User] the destination user, to which we will move *src*.
+  #
+  def run(cfg, plugin, src, dst)
 
     if src.is_a?(Domain) or dst.is_a?(Domain) then
       msg = 'only users can be moved'
@@ -16,24 +34,10 @@ class MvDummyRunner
     src_description = plugin.describe(src)
     dst_description = plugin.describe(dst)
 
-    msg  = "Would move user #{src} "
-
-    # Only append the extra description if it's useful.
-    if not src_description.nil? and
-       not src_description.empty? and
-       not src_description == src.to_s() then
-      msg += "(#{src_description}) "
-    end
-
-    msg += "to #{dst}"
-
-    # Only append the extra description if it's useful.
-    if not dst_description.nil? and
-       not dst_description.empty? and
-       not dst_description == dst.to_s() then
-      msg += " (#{dst_description})"
-    end
-
+    msg  = "Would move user "
+    msg += add_description(src, src_description)
+    msg += " to "
+    add_description(dst, dst_description)
     msg += "."
     report(plugin, msg)
   end