Class: AndOne::Formatter
- Inherits:
-
Object
- Object
- AndOne::Formatter
- Defined in:
- lib/and_one/formatter.rb
Overview
Formats N+1 detections into readable, actionable output.
Constant Summary collapse
- COLORS =
{ red: "\e[91m", yellow: "\e[93m", green: "\e[92m", cyan: "\e[96m", dim: "\e[2m", bold: "\e[1m", reset: "\e[0m" }.freeze
- SEPARATOR =
"─" * 70
Instance Method Summary collapse
- #format(detections) ⇒ Object
-
#initialize(backtrace_cleaner: nil) ⇒ Formatter
constructor
A new instance of Formatter.
Constructor Details
#initialize(backtrace_cleaner: nil) ⇒ Formatter
18 19 20 |
# File 'lib/and_one/formatter.rb', line 18 def initialize(backtrace_cleaner: nil) @backtrace_cleaner = backtrace_cleaner end |
Instance Method Details
#format(detections) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/and_one/formatter.rb', line 22 def format(detections) parts = [] parts << "" parts << colorize(SEPARATOR, :red) parts << colorize(" 🏀 And One! #{detections.size} N+1 quer#{detections.size == 1 ? "y" : "ies"} detected", :red, :bold) parts << colorize(SEPARATOR, :red) detections.each_with_index do |detection, i| parts << "" parts << format_detection(detection, i + 1) end parts << "" parts << colorize(SEPARATOR, :red) parts.join("\n") end |