Class: Hone::Reporter

Inherits:
Object
  • Object
show all
Includes:
Formatters::Filterable
Defined in:
lib/hone/reporter.rb

Constant Summary collapse

COLORS =

ANSI color codes

{
  reset: "\e[0m",
  bold: "\e[1m",
  dim: "\e[2m",
  red: "\e[31m",
  green: "\e[32m",
  yellow: "\e[33m",
  cyan: "\e[36m",
  white: "\e[37m",
  bright_red: "\e[91m",
  gray: "\e[90m"
}.freeze
PRIORITY_CONFIG =

Priority display configuration

{
  hot_cpu: {label: "High impact", color: %i[bold bright_red], metric: :cpu},
  hot_alloc: {label: "High impact", color: %i[bold red], metric: :alloc},
  jit_unfriendly: {label: "JIT issue", color: %i[bold yellow], metric: nil},
  warm: {label: "Moderate", color: [:yellow], metric: nil},
  cold: {label: "Low", color: %i[dim gray], metric: nil},
  unknown: {label: "Unknown", color: [:dim], metric: nil}
}.freeze
SEPARATOR_WIDTH =
72
CONTEXT_LINES =
2

Constants included from Formatters::Filterable

Formatters::Filterable::PRIORITY_LABELS

Instance Method Summary collapse

Methods included from Formatters::Filterable

#filter_cold, #priority_label

Constructor Details

#initialize(findings, options = {}) ⇒ Reporter

Returns a new instance of Reporter.



34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/hone/reporter.rb', line 34

def initialize(findings, options = {})
  @findings = findings
  @show_cold = options.fetch(:show_cold, false)
  @quiet = options.fetch(:quiet, false)
  @verbose = options.fetch(:verbose, false)
  @color = options.fetch(:color, $stdout.tty? && !ENV["NO_COLOR"])
  @profile_path = options[:profile_path]
  @file_path = options[:file_path]
  @hot_threshold = options.fetch(:hot_threshold, Correlator::HOT_THRESHOLD)
  @warm_threshold = options.fetch(:warm_threshold, Correlator::WARM_THRESHOLD)
  @source_cache = {}
end

Instance Method Details

#formatObject Also known as: report



47
48
49
50
51
52
53
# File 'lib/hone/reporter.rb', line 47

def format
  output = []
  output << header unless @quiet
  output << findings_output
  output << summary
  output.flatten.compact.join("\n")
end