Class: ActiveRecordQueryCount::Printer::Html
- Defined in:
- lib/active_record_query_count/printer/html.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
Instance Method Summary collapse
- #chart_data ⇒ Object
-
#initialize(data:) ⇒ Html
constructor
A new instance of Html.
- #inject_in_html ⇒ Object
- #print ⇒ Object
- #render_query_counter_base_div ⇒ Object
-
#total_query_count ⇒ Object
maybe this should not be filtered.
Methods inherited from Base
#css_content, #filter_data, #js_content, #open_file, #sort_data
Constructor Details
#initialize(data:) ⇒ Html
Returns a new instance of Html.
12 13 14 15 16 17 18 19 20 |
# File 'lib/active_record_query_count/printer/html.rb', line 12 def initialize data: @template_path = File.join(__dir__, 'templates', 'template.html.erb') @base_query_counter_path = File.join(__dir__, 'templates', 'template_base_query_counter.html.erb') @inject_template_path = File.join(__dir__, 'templates', 'template_for_inject.html.erb') @css_path = File.join(__dir__, 'templates', 'style.css') # este no falla, quizá pueda poner lo mismo aquí con chart.js y así no hacer lo del nonce y csp @js_path = File.join(__dir__, 'templates', 'bar_chart.js') @data = data end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
10 11 12 |
# File 'lib/active_record_query_count/printer/html.rb', line 10 def data @data end |
Instance Method Details
#chart_data ⇒ Object
22 23 24 |
# File 'lib/active_record_query_count/printer/html.rb', line 22 def chart_data @chart_data ||= generate_chart_data(data) end |
#inject_in_html ⇒ Object
31 32 33 |
# File 'lib/active_record_query_count/printer/html.rb', line 31 def inject_in_html ERB.new(File.read(@inject_template_path)).result(binding) end |
#print ⇒ Object
39 40 41 42 |
# File 'lib/active_record_query_count/printer/html.rb', line 39 def print html_dest = generate_html(binding) open_file(html_dest) end |
#render_query_counter_base_div ⇒ Object
35 36 37 |
# File 'lib/active_record_query_count/printer/html.rb', line 35 def render_query_counter_base_div ERB.new(File.read(@base_query_counter_path)).result(binding) end |
#total_query_count ⇒ Object
maybe this should not be filtered
27 28 29 |
# File 'lib/active_record_query_count/printer/html.rb', line 27 def total_query_count @total_query_count ||= data.values.sum { |v| v[:count] } end |