X-Git-Url: http://gitweb.michael.orlitzky.com/?p=mailshears.git;a=blobdiff_plain;f=lib%2Fmv%2Fmv_dummy_runner.rb;h=f73066967d3f42d41e6c3921b48a0b960ce1de8c;hp=ff612ffeb175e7bc4b663c0f18214055f5946890;hb=ef77e919fa61bb5ba7924d49a171dc3a05410a33;hpb=72696d3f6e95ef773af9727e9c3459b9038b0fc2 diff --git a/lib/mv/mv_dummy_runner.rb b/lib/mv/mv_dummy_runner.rb index ff612ff..f730669 100644 --- a/lib/mv/mv_dummy_runner.rb +++ b/lib/mv/mv_dummy_runner.rb @@ -1,14 +1,45 @@ require 'common/runner' +# Dummy implementation of a {MvRunner}. Its run() 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) - if src.include?('@') then - puts "Would move user: #{src} to #{dst}" - else - puts "Would move domain: #{src} to #{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' + raise NotImplementedError.new(msg) end + + # Since we're not actually moving anything, the destination + # description is really only useful for seeing whether or not we'd + # be trying to move in on top of an existing account. + src_description = plugin.describe(src) + dst_description = plugin.describe(dst) + + msg = "Would move user " + msg += add_description(src, src_description) + msg += " to " + add_description(dst, dst_description) + msg += "." + report(plugin, msg) end end