Class: GrafanaReporter::ERB::Report

Inherits:
AbstractReport show all
Defined in:
lib/grafana_reporter/erb/report.rb

Overview

Implementation of a specific AbstractReport. It is used to build reports specifically for erb templates.

Constant Summary

Constants inherited from AbstractReport

AbstractReport::EVENT_CALLBACKS

Instance Attribute Summary

Attributes inherited from AbstractReport

#cancel, #done, #end_time, #logger, #start_time, #template

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from AbstractReport

add_event_listener, #cancel!, clear_event_listeners, #create_report, #delete_file, #error, #execution_time, #full_log, #grafana, #initialize, #next_step, #path, #progress, #status

Constructor Details

This class inherits a constructor from GrafanaReporter::AbstractReport

Class Method Details

.default_result_extensionObject

See Also:

  • AbstractReport#default_result_extension


26
27
28
# File 'lib/grafana_reporter/erb/report.rb', line 26

def self.default_result_extension
  'txt'
end

.default_template_extensionObject

See Also:

  • AbstractReport#default_template_extension


21
22
23
# File 'lib/grafana_reporter/erb/report.rb', line 21

def self.default_template_extension
  'erb'
end

.demo_report_classesObject

See Also:

  • AbstractReport#demo_report_classes


31
32
33
# File 'lib/grafana_reporter/erb/report.rb', line 31

def self.demo_report_classes
  [DemoReportBuilder]
end

Instance Method Details

#buildObject

Starts to create an asciidoctor report. It utilizes all extensions in the Asciidoctor namespace to realize the conversion.



13
14
15
16
17
18
# File 'lib/grafana_reporter/erb/report.rb', line 13

def build
  attrs = @config.default_document_attributes.merge(@custom_attributes).merge({ 'grafana_report_timestamp' => ::Grafana::Variable.new(Time.now.to_s) })
  logger.debug("Document attributes: #{attrs}")

  File.write(path, ::ERB.new(File.read(@template)).result(ReportJail.new(self, attrs).bind))
end