Class: TestProf::Autopilot::EventProf::Report
- Inherits:
-
Object
- Object
- TestProf::Autopilot::EventProf::Report
- Extended by:
- ReportBuilder
- Defined in:
- lib/test_prof/autopilot/event_prof/report.rb
Overview
:event_prof report allows to add additional functionality for it’s instances
Constant Summary collapse
- ARTIFACT_FILE =
"event_prof_report.json"
Constants included from ReportBuilder
ReportBuilder::ARTIFACT_MISSING_HINT
Instance Attribute Summary collapse
-
#raw_report ⇒ Object
readonly
Returns the value of attribute raw_report.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(raw_report) ⇒ Report
constructor
A new instance of Report.
- #merge(other) ⇒ Object
- #paths ⇒ Object
Methods included from ReportBuilder
Constructor Details
#initialize(raw_report) ⇒ Report
Returns a new instance of Report.
20 21 22 23 |
# File 'lib/test_prof/autopilot/event_prof/report.rb', line 20 def initialize(raw_report) @type = :event_prof @raw_report = raw_report end |
Instance Attribute Details
#raw_report ⇒ Object (readonly)
Returns the value of attribute raw_report.
18 19 20 |
# File 'lib/test_prof/autopilot/event_prof/report.rb', line 18 def raw_report @raw_report end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
18 19 20 |
# File 'lib/test_prof/autopilot/event_prof/report.rb', line 18 def type @type end |
Instance Method Details
#merge(other) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/test_prof/autopilot/event_prof/report.rb', line 29 def merge(other) raise ArgumentError, "Incompatible events: #{raw_report["event"]} and #{other.raw_report["event"]}" if raw_report["event"] != other.raw_report["event"] report = raw_report.dup %w[total_time absolute_run_time total_count].each do |field| report[field] += other.raw_report[field] end report["time_percentage"] = (report["total_time"] / report["absolute_run_time"]) * 100 report["groups"] = (report["groups"] + other.raw_report["groups"]).sort { |a, b| b["time"] <=> a["time"] }.take(report["top_count"]) Report.new(report) end |
#paths ⇒ Object
25 26 27 |
# File 'lib/test_prof/autopilot/event_prof/report.rb', line 25 def paths @raw_report["groups"].reduce("") { |paths, group| "#{paths} #{group["location"]}" }.strip end |