Class: TestProf::Autopilot::ReportWriter
- Inherits:
-
Object
- Object
- TestProf::Autopilot::ReportWriter
- Includes:
- Logging
- Defined in:
- lib/test_prof/autopilot/report_writer.rb
Overview
Base class for report writers classes
Direct Known Subclasses
EventProf::Writer, FactoryDefault::Writer, FactoryProf::Writer, StackProf::Writer, TagProf::Writer
Instance Attribute Summary collapse
-
#report ⇒ Object
readonly
Returns the value of attribute report.
Class Method Summary collapse
Instance Method Summary collapse
- #generate_json ⇒ Object
-
#initialize(report) ⇒ ReportWriter
constructor
A new instance of ReportWriter.
- #write(file_name: nil, format: "json") ⇒ Object
Methods included from Logging
Constructor Details
#initialize(report) ⇒ ReportWriter
Returns a new instance of ReportWriter.
17 18 19 |
# File 'lib/test_prof/autopilot/report_writer.rb', line 17 def initialize(report) @report = report end |
Instance Attribute Details
#report ⇒ Object (readonly)
Returns the value of attribute report.
15 16 17 |
# File 'lib/test_prof/autopilot/report_writer.rb', line 15 def report @report end |
Class Method Details
.write_report(report, **options) ⇒ Object
10 11 12 |
# File 'lib/test_prof/autopilot/report_writer.rb', line 10 def write_report(report, **) new(report).write(**) end |
Instance Method Details
#generate_json ⇒ Object
36 37 |
# File 'lib/test_prof/autopilot/report_writer.rb', line 36 def generate_json end |
#write(file_name: nil, format: "json") ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/test_prof/autopilot/report_writer.rb', line 21 def write(file_name: nil, format: "json") file_path = file_name || self.class::ARTIFACT_FILE if File.absolute_path?(file_path) FileUtils.mkdir_p(File.dirname(file_path)) else dir_path = FileUtils.mkdir_p(Autopilot.config.artifacts_dir)[0] file_path = File.join(dir_path, file_path + ".#{format}") end File.write(file_path, public_send("generate_#{format}")) log "Report saved: #{file_path}" end |