Class: TestProf::Autopilot::TagProf::Report
- Inherits:
-
Object
- Object
- TestProf::Autopilot::TagProf::Report
- Extended by:
- ReportBuilder
- Defined in:
- lib/test_prof/autopilot/tag_prof/report.rb
Overview
:tag_prof report allows to add additional functionality for it’s instances
Constant Summary collapse
- ARTIFACT_FILE =
"tag_prof_report.json"
- SYMBOLIC_DATA_KEYS =
%w[value count time].freeze
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
- #result ⇒ Object
Methods included from ReportBuilder
Constructor Details
#initialize(raw_report) ⇒ Report
Returns a new instance of Report.
23 24 25 26 |
# File 'lib/test_prof/autopilot/tag_prof/report.rb', line 23 def initialize(raw_report) @type = :tag_prof @raw_report = raw_report end |
Instance Attribute Details
#raw_report ⇒ Object (readonly)
Returns the value of attribute raw_report.
21 22 23 |
# File 'lib/test_prof/autopilot/tag_prof/report.rb', line 21 def raw_report @raw_report end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
21 22 23 |
# File 'lib/test_prof/autopilot/tag_prof/report.rb', line 21 def type @type end |
Instance Method Details
#merge(other) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/test_prof/autopilot/tag_prof/report.rb', line 38 def merge(other) raise ArgumentError, "Tags must be identical: #{raw_report["tag"]} and #{other.raw_report["tag"]}" unless raw_report["tag"] == other.raw_report["tag"] new_report = raw_report.dup (raw_report["data"] + other.raw_report["data"]).each_with_object({}) do |tag_data, acc| if acc.key?(tag_data["value"]) el = acc[tag_data["value"]] tag_data.each do |field, val| next if field == "value" next unless el.key?(field) el[field] += val end else acc[tag_data["value"]] = tag_data.dup end end.then do |new_data| new_report["data"] = new_data.values end Report.new(new_report) end |
#result ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/test_prof/autopilot/tag_prof/report.rb', line 28 def result @result ||= TestProf::TagProf::Result.new(raw_report["tag"], raw_report["events"]).tap do |result| raw_report["data"].each do |tag_data| result.data[tag_data["value"]] = tag_data.transform_keys do |key| SYMBOLIC_DATA_KEYS.include?(key) ? key.to_sym : key end end end end |