Class: ActiverecordCallbackLens::Renderer::HtmlRenderer
- Inherits:
-
Object
- Object
- ActiverecordCallbackLens::Renderer::HtmlRenderer
- Defined in:
- lib/activerecord_callback_lens/renderer/html_renderer.rb
Overview
Renders a self-contained HTML report for a model’s callbacks.
The document embeds five sections (spec section 8.3):
-
Callback List — a table with columns Phase, Event, Filter, Conditions.
-
Execution Flow — an ordered list sorted by ExecutionOrderAnalyzer (the
:createpath). -
Dependency Tree — a nested <ul> built from each definition’s ConditionTree (via ConditionTreeHtml).
-
Mermaid Diagram — a <pre class=“mermaid”> block populated by MermaidRenderer and rendered client-side via the Mermaid CDN script.
-
Graphviz SVG — the inline <svg> produced by GraphvizRenderer#to_svg when the
dotbinary is available; the section is omitted otherwise.
All user-derived text is HTML escaped with CGI.escapeHTML.
Constant Summary collapse
- MERMAID_CDN =
The Mermaid.js bundle loaded from a CDN so the report stays a single, dependency-free HTML file.
"https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js"
Class Method Summary collapse
-
.render(graph, definitions:) ⇒ String
A complete HTML document.
Instance Method Summary collapse
-
#initialize(graph, definitions) ⇒ HtmlRenderer
constructor
A new instance of HtmlRenderer.
-
#render ⇒ String
Assembles the full HTML document.
Constructor Details
#initialize(graph, definitions) ⇒ HtmlRenderer
Returns a new instance of HtmlRenderer.
107 108 109 110 |
# File 'lib/activerecord_callback_lens/renderer/html_renderer.rb', line 107 def initialize(graph, definitions) @graph = graph @definitions = definitions end |
Class Method Details
.render(graph, definitions:) ⇒ String
Returns a complete HTML document.
101 102 103 |
# File 'lib/activerecord_callback_lens/renderer/html_renderer.rb', line 101 def self.render(graph, definitions:) new(graph, definitions).render end |
Instance Method Details
#render ⇒ String
Assembles the full HTML document.
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/activerecord_callback_lens/renderer/html_renderer.rb', line 115 def render <<~HTML <!DOCTYPE html> <html> <head><meta charset="utf-8"><title>Callback Lens</title></head> <body> #{callback_table} #{execution_flow} #{dependency_trees} #{mermaid_section} #{svg_section} <script src="#{MERMAID_CDN}"></script> <script>mermaid.initialize({startOnLoad:true});</script> </body> </html> HTML end |