]> gitweb.michael.orlitzky.com - mailshears.git/blob - lib/prune/prune_dummy_runner.rb
mailshears.gemspec: update the version to 0.0.5.
[mailshears.git] / lib / prune / prune_dummy_runner.rb
1 require 'common/runner'
2 require 'prune/plugins/postfixadmin'
3 require 'rm/rm_dummy_runner'
4
5 # Dummy implementation of a {PruneRunner}. Its <tt>run()</tt> method will
6 # tell you what would have been pruned, but will not actually perform
7 # the operation.
8 #
9 class PruneDummyRunner
10 include Runner
11
12
13 # Pretend to prune unused domains and users. Some "what if"
14 # information will be output to stdout.
15 #
16 # The prune mode is the main application of the "dummy" runners,
17 # since it performs some computation outside of the plugins
18 # themselves. This lets the user know which users and domains would
19 # be removed and can help prevent mistakes or even find bugs in the
20 # prune code, if it looks like something will be removed that
21 # shouldn't be!
22 #
23 # @param cfg [Configuration] the configuration options to pass to
24 # the *plugin* we're runnning.
25 #
26 # @param plugin [Class] plugin class that will do the pruning.
27 #
28 def run(cfg, plugin)
29 # We don't want to check the PostfixAdmin database against itself.
30 return if plugin.class == PostfixadminPrune
31
32 pfa = PostfixadminPrune.new(cfg)
33
34 db_users = pfa.list_users()
35 db_domains = pfa.list_domains()
36
37 leftovers = plugin.get_leftover_users(db_users)
38 leftovers += plugin.get_leftover_domains(db_domains)
39
40 rm_dummy_runner = RmDummyRunner.new()
41 rm_dummy_runner.run(cfg, plugin, *leftovers)
42 end
43
44 end