Class: QueryTracker::Printer::Html
- Inherits:
-
Base
- Object
- Base
- QueryTracker::Printer::Html
show all
- Defined in:
- lib/query_tracker/printer/html.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Base
#css_content, #filter_data, #js_content, #open_file, #sort_data
Constructor Details
#initialize(data:) ⇒ Html
12
13
14
15
16
17
18
19
20
|
# File 'lib/query_tracker/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')
@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/query_tracker/printer/html.rb', line 10
def data
@data
end
|
Instance Method Details
#chart_data ⇒ Object
22
23
24
|
# File 'lib/query_tracker/printer/html.rb', line 22
def chart_data
@chart_data ||= generate_chart_data(data)
end
|
#inject_in_html ⇒ Object
31
32
33
|
# File 'lib/query_tracker/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/query_tracker/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/query_tracker/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/query_tracker/printer/html.rb', line 27
def total_query_count
@total_query_count ||= data.values.sum { |v| v[:count] }
end
|