Class/Module Index [+]

Quicksearch

RR::ScanReportPrinters::ScanDetailReporter

A ScanReportPrinter producing a summary (number of differences) only.

Attributes

primary_key_names[RW]

Array of names of the primary key columns of the table currently being scanned.

report_mode[RW]

Mode of reporting. Should be either

  • :full

  • :keys or

  • :diff

session[RW]

The current Session object

tmpfile[RW]

The temporary File receiving the differences

Public Class Methods

new(session, arg) click to toggle source

A scan run is to be started using this scan result printer. arg is the command line argument as yielded by OptionParser#on.

# File lib/rubyrep/scan_report_printers/scan_detail_reporter.rb, line 39
def initialize(session, arg)
  super session, ""
  self.session = session

  self.report_mode = case arg
  when 'diff'
    :diff
  when 'keys'
    :keys
  else
    :full
  end
end

Public Instance Methods

clear_columns(row) click to toggle source

Returns a cleaned row as per current report_mode. row is either a column_name => value hash or an array of 2 such rows.

# File lib/rubyrep/scan_report_printers/scan_detail_reporter.rb, line 72
def clear_columns(row)
  case report_mode
  when :full
    row
  when :keys
    row = row[0] if row.kind_of?(Array)
    self.primary_key_names ||= session.left.primary_key_names(self.left_table)
    row.reject {|column, value| !self.primary_key_names.include?(column)}
  when :diff
    self.primary_key_names ||= session.left.primary_key_names(self.left_table)
    if row.kind_of?(Array)
      new_row_array = [{}, {}]
      row[0].each do |column, value|
        if self.primary_key_names.include?(column) or value != row[1][column]
          new_row_array[0][column] = row[0][column]
          new_row_array[1][column] = row[1][column]
        end
      end
      new_row_array
    else
      row
    end
  end
end
report_difference(type, row) click to toggle source

Each difference is handed to the printer as described in the format as described e. g. in DirectTableScan#run

# File lib/rubyrep/scan_report_printers/scan_detail_reporter.rb, line 99
def report_difference(type, row)
  self.tmpfile ||= Tempfile.new 'rubyrep_scan_details'
  tmpfile.puts({type => clear_columns(row)}.to_yaml)
  super type, row
end
scan(left_table, right_table) click to toggle source

A scan of the given 'left' table and corresponding 'right' table is executed. Needs to yield so that the actual scan can be executed.

# File lib/rubyrep/scan_report_printers/scan_detail_reporter.rb, line 55
def scan(left_table, right_table)

  super left_table, right_table

ensure
  self.primary_key_names = nil
  if self.tmpfile
    self.tmpfile.close
    self.tmpfile.open
    self.tmpfile.each_line {|line| puts line}
    self.tmpfile.close!
    self.tmpfile = nil
  end
end
scanning_finished() click to toggle source

Optional method. If a scan report printer has it, it is called after the last table scan is executed. (A good place to print a final summary.)

# File lib/rubyrep/scan_report_printers/scan_detail_reporter.rb, line 108
def scanning_finished
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.