Class: Ace::Support::Config::Molecules::SetupDoctorReporter
- Inherits:
-
Object
- Object
- Ace::Support::Config::Molecules::SetupDoctorReporter
- Defined in:
- lib/ace/support/config/molecules/setup_doctor_reporter.rb
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 =
{ doctor: "š„", stats: "š", success: "ā ", error: "ā", warning: "ā ļø", info: "ā¹ļø" }.freeze
- STATUS_GLYPHS =
{ "pass" => "ā", "warn" => "ā", "blocker" => "ā", "skip" => "ā", "info" => "ā" }.freeze
- STATUS_COLORS =
{ "pass" => :green, "warn" => :yellow, "blocker" => :red, "skip" => :yellow, "info" => :cyan }.freeze
Class Method Summary collapse
- .format_recommendations(profile, findings, strict: false) ⇒ Object
- .format_results(results, format: :terminal, hygiene: false, verbose: false, colors: true) ⇒ Object
Instance Method Summary collapse
- #format_terminal ⇒ Object
-
#initialize(results, hygiene:, verbose:, colors:) ⇒ SetupDoctorReporter
constructor
A new instance of SetupDoctorReporter.
Constructor Details
#initialize(results, hygiene:, verbose:, colors:) ⇒ SetupDoctorReporter
Returns a new instance of SetupDoctorReporter.
104 105 106 107 108 109 |
# File 'lib/ace/support/config/molecules/setup_doctor_reporter.rb', line 104 def initialize(results, hygiene:, verbose:, colors:) @results = results @hygiene = hygiene @verbose = verbose @colors = colors end |
Class Method Details
.format_recommendations(profile, findings, strict: false) ⇒ Object
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 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/ace/support/config/molecules/setup_doctor_reporter.rb', line 54 def self.format_recommendations(profile, findings, strict: false) output = [] output << "\nš„ Configuration Recommendations (Profile: #{profile})" output << "=" * 50 output << "" # Separate acknowledged from visible findings visible = findings.reject { |f| f[:severity] == "acknowledged" } acknowledged_count = findings.count { |f| f[:severity] == "acknowledged" } if visible.empty? && acknowledged_count.zero? output << "ā No recommendations found - configuration matches profile '#{profile}'." elsif visible.empty? output << "ā All findings acknowledged (#{acknowledged_count} active)." else visible.each_with_index do |f, idx| glyph = case f[:severity] when "blocker" then "ā" when "warning" then "ā ļø" when "recommendation" then "š”" else "ā¹ļø" end output << "#{idx + 1}. #{glyph} [#{f[:severity].upcase}] #{f[:id]}" output << " Source: #{f[:resolved_source]} | Version: #{f[:version]}" output << " Current: #{f[:current_value]}" output << " Recommended: #{f[:recommended_value]}" output << " Rationale: #{f[:rationale]}" if f[:rationale] output << " Next Action: #{f[:next_action]}" if f[:next_action] if f[:acknowledgement_expired] && f[:acknowledgement] ack = f[:acknowledgement] output << " Prior Acknowledgement Expired: #{ack["rationale"]} (by #{ack["actor"]})" end output << "" end if acknowledged_count.positive? output << " (#{acknowledged_count} finding#{"s" if acknowledged_count > 1} suppressed by active acknowledgement#{"s" if acknowledged_count > 1})" output << "" end end output << "=" * 50 has_failures = findings.any? { |f| %w[blocker warning].include?(f[:severity]) } if strict && has_failures output << "\e[31mRecommendation check failed under strict mode\e[0m" else output << "\e[32mRecommendation check completed\e[0m" end output.join("\n") end |
.format_results(results, format: :terminal, hygiene: false, verbose: false, colors: true) ⇒ Object
45 46 47 48 49 50 51 52 |
# File 'lib/ace/support/config/molecules/setup_doctor_reporter.rb', line 45 def self.format_results(results, format: :terminal, hygiene: false, verbose: false, colors: true) case format.to_sym when :json JSON.pretty_generate(results) else new(results, hygiene: hygiene, verbose: verbose, colors: colors).format_terminal end end |
Instance Method Details
#format_terminal ⇒ Object
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/ace/support/config/molecules/setup_doctor_reporter.rb', line 111 def format_terminal output = [] output << "\n#{colorize("#{ICONS[:doctor]} Setup Health Check", :bold)}" output << "=" * 40 output.concat(format_overview) output.concat(format_readiness) output.concat(format_info) output.concat(format_provider_pings) output.concat(format_issues) output << "=" * 40 output << format_summary_line output << "\n#{colorize("Completed in #{format_duration(@results[:duration])}", :blue)}" if @results[:duration] output << final_status_line output.join("\n") end |