Class: Ace::Task::Molecules::TaskDoctorReporter

Inherits:
Object
  • Object
show all
Defined in:
lib/ace/task/molecules/task_doctor_reporter.rb

Overview

Formats doctor diagnosis results for terminal, JSON, or summary output.

Constant Summary collapse

COLORS =
{
  red: "\e[31m",
  yellow: "\e[33m",
  green: "\e[32m",
  blue: "\e[34m",
  cyan: "\e[36m",
  reset: "\e[0m",
  bold: "\e[1m"
}.freeze
ICONS =
{
  error: "",
  warning: "⚠️",
  info: "ℹ️",
  success: "",
  doctor: "🏥",
  stats: "📊",
  search: "🔍",
  fix: "🔧",
  score: "📈"
}.freeze

Class Method Summary collapse

Class Method Details

.format_fix_results(fix_results, colors: true) ⇒ String

Format auto-fix results

Parameters:

  • fix_results (Hash)

    Results from TaskDoctorFixer#fix_issues

  • colors (Boolean) (defaults to: true)

    Enable colored output

Returns:

  • (String)

    Formatted fix output



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/ace/task/molecules/task_doctor_reporter.rb', line 53

def self.format_fix_results(fix_results, colors: true)
  output = []

  output << if fix_results[:dry_run]
    "\n#{colorize("#{ICONS[:search]} DRY RUN MODE", :cyan, colors)} - No changes applied"
  else
    "\n#{colorize("#{ICONS[:fix]} Auto-Fix Applied", :green, colors)}"
  end

  if fix_results[:fixed] > 0
    output << "#{colorize("Fixed:", :green, colors)} #{fix_results[:fixed]} issues"

    if fix_results[:fixes_applied]&.any?
      output << "\nFixes applied:"
      fix_results[:fixes_applied].each do |fix|
        output << "  #{colorize("", :green, colors)} #{fix[:description]}"
        output << "    #{colorize(fix[:file], :blue, colors)}" if fix[:file]
      end
    end
  end

  if fix_results[:skipped] > 0
    output << "#{colorize("Skipped:", :yellow, colors)} #{fix_results[:skipped]} issues (manual fix required)"
  end

  output.join("\n")
end

.format_results(results, format: :terminal, verbose: false, colors: true) ⇒ String

Format diagnosis results

Parameters:

  • results (Hash)

    Results from TaskDoctor#run_diagnosis

  • format (Symbol) (defaults to: :terminal)

    Output format (:terminal, :json, :summary)

  • verbose (Boolean) (defaults to: false)

    Show verbose output

  • colors (Boolean) (defaults to: true)

    Enable colored output

Returns:

  • (String)

    Formatted output



38
39
40
41
42
43
44
45
46
47
# File 'lib/ace/task/molecules/task_doctor_reporter.rb', line 38

def self.format_results(results, format: :terminal, verbose: false, colors: true)
  case format.to_sym
  when :json
    format_json(results)
  when :summary
    format_summary(results, colors: colors)
  else
    format_terminal(results, verbose: verbose, colors: colors)
  end
end