Class: Pcrd::Output::AnalyzePrinter
- Inherits:
-
Object
- Object
- Pcrd::Output::AnalyzePrinter
- Defined in:
- lib/pcrd/output/analyze_printer.rb
Constant Summary collapse
- PASTEL =
Pastel.new
- STATUS_COLORS =
{ unchanged: ->(s) { s }, type_changed: ->(s) { PASTEL.yellow(s) }, renamed: ->(s) { PASTEL.cyan(s) }, type_and_renamed: ->(s) { PASTEL.yellow(s) }, dropped: ->(s) { PASTEL.red(s) }, added: ->(s) { PASTEL.green(s) } }.freeze
Instance Method Summary collapse
-
#initialize(output: $stdout) ⇒ AnalyzePrinter
constructor
A new instance of AnalyzePrinter.
-
#print_diff_report(table_name:, schema_name: "public", row_count:, diff_entries:, packer:, target_is_live: false) ⇒ Object
Cross-cluster diff: source schema vs.
-
#print_table_report(table_name:, schema_name: "public", row_count:, report:) ⇒ Object
Single-cluster padding analysis: current layout vs.
Constructor Details
#initialize(output: $stdout) ⇒ AnalyzePrinter
Returns a new instance of AnalyzePrinter.
21 22 23 |
# File 'lib/pcrd/output/analyze_printer.rb', line 21 def initialize(output: $stdout) @out = output end |
Instance Method Details
#print_diff_report(table_name:, schema_name: "public", row_count:, diff_entries:, packer:, target_is_live: false) ⇒ Object
Cross-cluster diff: source schema vs. target (live or synthesized from spec).
49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/pcrd/output/analyze_printer.rb', line 49 def print_diff_report(table_name:, schema_name: "public", row_count:, diff_entries:, packer:, target_is_live: false) heading = "Table: #{schema_name}.#{table_name}" heading += " (#{format_count(row_count)} rows)" if row_count > 0 heading += target_is_live ? " — live source vs. live target" \ : " — source vs. proposed target (synthesized from spec)" @out.puts @out.puts PASTEL.bold(heading) @out.puts print_diff_table(diff_entries) @out.puts print_diff_padding_summary(diff_entries, packer, row_count) end |
#print_table_report(table_name:, schema_name: "public", row_count:, report:) ⇒ Object
Single-cluster padding analysis: current layout vs. optimal reordering.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/pcrd/output/analyze_printer.rb', line 26 def print_table_report(table_name:, schema_name: "public", row_count:, report:) heading = "Table: #{schema_name}.#{table_name}" heading += " (#{format_count(row_count)} rows)" if row_count > 0 @out.puts @out.puts PASTEL.bold(heading) @out.puts if report[:already_optimal] @out.puts PASTEL.green(" ✓ Column order is already optimal. No padding waste detected.") @out.puts print_layout_table(report[:current_layout], title: "Current layout") return end print_layout_table(report[:current_layout], title: "Current layout", highlight_padding: true) @out.puts print_savings_summary(report, row_count) @out.puts print_layout_table(report[:optimal_layout], title: "Suggested layout (optimal packing)") end |