Class: Pcrd::Output::CutoverPrinter
- Inherits:
-
Object
- Object
- Pcrd::Output::CutoverPrinter
- Defined in:
- lib/pcrd/output/cutover_printer.rb
Constant Summary collapse
- PASTEL =
Pastel.new
Instance Method Summary collapse
-
#initialize(output: $stdout) ⇒ CutoverPrinter
constructor
A new instance of CutoverPrinter.
- #print(result) ⇒ Object
- #print_verify(result) ⇒ Object
Constructor Details
#initialize(output: $stdout) ⇒ CutoverPrinter
Returns a new instance of CutoverPrinter.
10 11 12 |
# File 'lib/pcrd/output/cutover_printer.rb', line 10 def initialize(output: $stdout) @out = output end |
Instance Method Details
#print(result) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/pcrd/output/cutover_printer.rb', line 14 def print(result) @out.puts @out.puts PASTEL.bold("Cutover report") @out.puts PASTEL.dim("─" * 70) @out.puts print_row_counts(result.row_counts) print_sequences(result.sequence_results) print_warnings(result.warnings) print_summary(result) end |
#print_verify(result) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/pcrd/output/cutover_printer.rb', line 26 def print_verify(result) @out.puts @out.puts PASTEL.bold("Verify results") @out.puts PASTEL.dim("─" * 70) @out.puts result.tables.each do |t| src = t.source_count tgt = t.target_count if src.nil? @out.puts " #{PASTEL.red("✗")} #{t.table_name} #{PASTEL.red(t.mismatches.first)}" next end if src == tgt suffix = t.mismatches.empty? ? "" : PASTEL.yellow(" (#{t.mismatches.length} spot-check mismatch(es))") @out.puts " #{PASTEL.green("✓")} #{t.table_name} " \ "#{PASTEL.dim("#{format_count(src)} rows match")}#{suffix}" else @out.puts " #{PASTEL.red("✗")} #{t.table_name} " \ "source=#{format_count(src)} target=#{format_count(tgt)} " \ "#{PASTEL.red("count mismatch")}" end end @out.puts if result.passed @out.puts " #{PASTEL.green("✓")} #{PASTEL.bold("All tables verified.")}" else @out.puts " #{PASTEL.red("✗")} #{PASTEL.bold(PASTEL.red("Verification failed."))}" end @out.puts end |