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 thedotbinary 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:, expand: false) ⇒ String
A complete HTML document.
Instance Method Summary collapse
-
#initialize(graph, definitions, expand: false) ⇒ HtmlRenderer
constructor
A new instance of HtmlRenderer.
-
#render ⇒ String
Assembles the full HTML document.
Constructor Details
#initialize(graph, definitions, expand: false) ⇒ HtmlRenderer
Returns a new instance of HtmlRenderer.
109 110 111 112 113 |
# File 'lib/activerecord_callback_lens/renderer/html_renderer.rb', line 109 def initialize(graph, definitions, expand: false) @graph = graph @definitions = definitions = end |
Class Method Details
.render(graph, definitions:, expand: false) ⇒ String
Returns a complete HTML document.
102 103 104 |
# File 'lib/activerecord_callback_lens/renderer/html_renderer.rb', line 102 def self.render(graph, definitions:, expand: false) new(graph, definitions, expand: ).render end |
Instance Method Details
#render ⇒ String
Assembles the full HTML document.
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/activerecord_callback_lens/renderer/html_renderer.rb', line 118 def render " <!DOCTYPE html>\n <html>\n <head><meta charset=\"utf-8\"><title>Callback Lens</title></head>\n <body>\n \#{callback_table}\n \#{execution_flow}\n \#{dependency_trees}\n \#{mermaid_section}\n \#{svg_section}\n <script src=\"\#{MERMAID_CDN}\"></script>\n <script>mermaid.initialize({startOnLoad:true});</script>\n </body>\n </html>\n HTML\nend\n" |