Module: RR::ScanProgressPrinters

Defined in:
lib/rubyrep/scan_progress_printers/scan_progress_printers.rb,
lib/rubyrep/scan_progress_printers/progress_bar.rb

Overview

Manages scan progress printers. Scan progress printers implement functionality to report the progress of a table scan. Each table scan is handled by a separate printer instance.

Scan progress printers need to register themselves and their command line options with #register.

A scan progress printer needs to implement at the minimum the following functionality:

# Receives the command line argument as yielded by OptionParser#on.
def self.arg=(arg)

# Creation of a new ScanProgressPrinter.
# * +max_steps+: number of steps at completion
# * +session+: the current Session
# * +left_table+: name of the left database table
# * +right_table+: name of the right database table
def initialize(max_steps, left_table, right_table)

# Progress is advanced by +progress+ number of steps.
def step(progress)

Defined Under Namespace

Classes: ProgressBar

Class Method Summary collapse

Class Method Details

.on_printer_selection(opts) ⇒ Object

Registers all report printer command line options into the given OptionParser. Once the command line is parsed with OptionParser#parse! it will yield the correct printer class.

Note: If multiple printers are specified in the command line, all are yielded.



56
57
58
59
60
61
62
63
# File 'lib/rubyrep/scan_progress_printers/scan_progress_printers.rb', line 56

def self.on_printer_selection(opts)
  printers.each_value do |printer|
    opts.on(*printer[:opts]) do |arg|
      printer[:printer_class].arg = arg
      yield printer[:printer_class]
    end
  end
end

.printersObject

Hash of registered ScanProgressPrinters. Each entry is a hash with the following key and related value:

  • key: Identifier of the progress printer

  • value: A hash with payload information. Possible values:

    • :printer_class: The ScanProgressPrinter class.

    • :opts: An array defining the command line options (handed to OptionParter#on).



33
34
35
# File 'lib/rubyrep/scan_progress_printers/scan_progress_printers.rb', line 33

def self.printers
  @@progress_printers ||= {}
end

.register(printer_id, printer_class, *opts) ⇒ Object

Needs to be called by ScanProgressPrinters to register themselves (printer) and their command line options.

  • :printer_id is the symbol through which the printer can be referenced.

  • :printer_class is the ScanProgressPrinter class,

  • :opts is an array defining the command line options (handed to OptionParter#on).



42
43
44
45
46
47
# File 'lib/rubyrep/scan_progress_printers/scan_progress_printers.rb', line 42

def self.register(printer_id, printer_class, *opts)
  printers[printer_id] = {
    :printer_class => printer_class,
    :opts => opts
  }
end