Class: Omamori::ReportGenerator::HTMLFormatter
- Inherits:
-
Object
- Object
- Omamori::ReportGenerator::HTMLFormatter
- Defined in:
- lib/omamori/report_generator/html_formatter.rb
Instance Method Summary collapse
- #format(combined_results) ⇒ Object
-
#initialize(output_path_prefix, template_path = nil) ⇒ HTMLFormatter
constructor
A new instance of HTMLFormatter.
Constructor Details
#initialize(output_path_prefix, template_path = nil) ⇒ HTMLFormatter
Returns a new instance of HTMLFormatter.
8 9 10 11 12 13 14 15 |
# File 'lib/omamori/report_generator/html_formatter.rb', line 8 def initialize(output_path_prefix, template_path = nil) @output_path_prefix = output_path_prefix # Use provided template_path if not nil, otherwise use default @template_path = template_path || File.join(__dir__, "report_template.erb") @template = ERB.new(File.read(@template_path)) rescue Errno::ENOENT raise "HTML template file not found at #{@template_path}" # Raise error if template is not found end |
Instance Method Details
#format(combined_results) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/omamori/report_generator/html_formatter.rb', line 17 def format(combined_results) # Prepare data for the template @ai_risks = combined_results && combined_results["ai_security_risks"] ? combined_results["ai_security_risks"] : [] @static_results = combined_results && combined_results["static_analysis_results"] ? combined_results["static_analysis_results"] : {} # Render the template @template.result(binding) rescue Errno::ENOENT "Error: HTML template file not found." rescue => e "Error generating HTML report: #{e.message}" end |