Module: Canon::DiffFormatter::DiffDetailFormatter
- Defined in:
- lib/canon/diff_formatter/diff_detail_formatter.rb
Overview
Formats dimension-specific detail for individual differences Provides actionable, colorized output showing exactly what changed
Class Method Summary collapse
-
.format_report(differences, use_color: true) ⇒ String
Format all differences as a semantic diff report.
Class Method Details
.format_report(differences, use_color: true) ⇒ String
Format all differences as a semantic diff report
23 24 25 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 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/canon/diff_formatter/diff_detail_formatter.rb', line 23 def format_report(differences, use_color: true) return "" if differences.empty? # Group differences by normative status normative = differences.select do |diff| diff.respond_to?(:normative?) ? diff.normative? : true end informative = differences.select do |diff| diff.respond_to?(:normative?) && !diff.normative? end output = [] output << "" output << colorize("=" * 70, :cyan, use_color, bold: true) output << colorize( " SEMANTIC DIFF REPORT (#{differences.length} #{differences.length == 1 ? 'difference' : 'differences'})", :cyan, use_color, bold: true ) output << colorize("=" * 70, :cyan, use_color, bold: true) # Show normative differences first if normative.any? output << "" output << colorize( "┌─ NORMATIVE DIFFERENCES (#{normative.length}) ─┐", :green, use_color, bold: true ) normative.each_with_index do |diff, i| output << "" output << format_single_diff(diff, i + 1, normative.length, use_color, section: "NORMATIVE") end end # Show informative differences second if informative.any? output << "" output << "" output << colorize( "┌─ INFORMATIVE DIFFERENCES (#{informative.length}) ─┐", :yellow, use_color, bold: true ) informative.each_with_index do |diff, i| output << "" output << format_single_diff(diff, i + 1, informative.length, use_color, section: "INFORMATIVE") end end output << "" output << colorize("=" * 70, :cyan, use_color, bold: true) output << "" output.join("\n") end |