Class: PruneDummyRunner

Inherits:
Object
  • Object
show all
Includes:
Runner
Defined in:
lib/prune/prune_dummy_runner.rb

Overview

Dummy implementation of a PruneRunner. Its run() method will tell you what would have been pruned, but will not actually perform the operation.

Instance Method Summary collapse

Methods included from Runner

#add_description, #pointless?, #report

Instance Method Details

#run(cfg, plugin) ⇒ Object

Pretend to prune unused domains and users. Some “what if” information will be output to stdout.

The prune mode is the main application of the “dummy” runners, since it performs some computation outside of the plugins themselves. This lets the user know which users and domains would be removed and can help prevent mistakes or even find bugs in the prune code, if it looks like something will be removed that shouldn’t be!

Parameters:

  • cfg (Configuration)

    the configuration options to pass to the plugin we’re runnning.

  • plugin (Class)

    plugin class that will do the pruning.



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/prune/prune_dummy_runner.rb', line 28

def run(cfg, plugin)
  # We don't want to check the PostfixAdmin database against itself.
  return if plugin.class == PostfixadminPrune

  pfa = PostfixadminPrune.new(cfg)

  db_users = pfa.list_users()
  db_domains = pfa.list_domains()

  leftovers  = plugin.get_leftover_users(db_users)
  leftovers += plugin.get_leftover_domains(db_domains)

  rm_dummy_runner = RmDummyRunner.new()
  rm_dummy_runner.run(cfg, plugin, *leftovers)
end