]>
gitweb.michael.orlitzky.com - mailshears.git/blob - lib/mv/mv_dummy_runner.rb
9ed655a4719ad30785b9a917624bc3dadfd7c768
1 require 'common/runner'
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
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.
15 # @param cfg [Configuration] the configuration options to pass to
16 # the *plugin* we're runnning.
18 # @param plugin [Class] plugin class that will perform the move.
20 # @param src [User] the source user to be moved.
22 # @param dst [User] the destination user, to which we will move *src*.
24 def run(cfg
, plugin
, src
, dst
)
26 if src
.is_a
?(Domain
) or dst
.is_a
?(Domain
) then
27 msg
= 'only users can be moved'
28 raise NotImplementedError
.new(msg
)
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
)
37 msg
= "Would move user #{src} "
39 # Only append the extra description if it's useful.
40 if not src_description
.nil? and
41 not src_description
.empty
? and
42 not src_description
== src
.to_s() then
43 msg +
= "(#{src_description}) "
48 # Only append the extra description if it's useful.
49 if not dst_description
.nil? and
50 not dst_description
.empty
? and
51 not dst_description
== dst
.to_s() then
52 msg +
= " (#{dst_description})"