Class: AbideDevUtils::CEM::Generate::CoverageReport::ReportOutput
- Inherits:
-
Object
- Object
- AbideDevUtils::CEM::Generate::CoverageReport::ReportOutput
- Defined in:
- lib/abide_dev_utils/cem/generate/coverage_report.rb
Overview
Class manages organizing report data into various output formats
Instance Attribute Summary collapse
-
#controls_in_resource_data ⇒ Object
readonly
Returns the value of attribute controls_in_resource_data.
-
#rules_in_map ⇒ Object
readonly
Returns the value of attribute rules_in_map.
-
#timestamp ⇒ Object
readonly
Returns the value of attribute timestamp.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
- #benchmark_hash ⇒ Object
- #coverage_hash ⇒ Object
- #covered ⇒ Object
- #covered_count ⇒ Object
-
#initialize(benchmark, controls_in_resource_data, rules_in_map) ⇒ ReportOutput
constructor
A new instance of ReportOutput.
- #percentage ⇒ Object
- #to_h ⇒ Object
- #to_json(opts = nil) ⇒ Object
- #to_yaml ⇒ Object
- #total_count ⇒ Object
- #uncovered ⇒ Object
- #uncovered_count ⇒ Object
Constructor Details
#initialize(benchmark, controls_in_resource_data, rules_in_map) ⇒ ReportOutput
Returns a new instance of ReportOutput.
236 237 238 239 240 241 242 |
# File 'lib/abide_dev_utils/cem/generate/coverage_report.rb', line 236 def initialize(benchmark, controls_in_resource_data, rules_in_map) @benchmark = benchmark @controls_in_resource_data = controls_in_resource_data @rules_in_map = rules_in_map @timestamp = DateTime.now.iso8601 @title = "Coverage Report for #{@benchmark.title_key}" end |
Instance Attribute Details
#controls_in_resource_data ⇒ Object (readonly)
Returns the value of attribute controls_in_resource_data.
233 234 235 |
# File 'lib/abide_dev_utils/cem/generate/coverage_report.rb', line 233 def controls_in_resource_data @controls_in_resource_data end |
#rules_in_map ⇒ Object (readonly)
Returns the value of attribute rules_in_map.
233 234 235 |
# File 'lib/abide_dev_utils/cem/generate/coverage_report.rb', line 233 def rules_in_map @rules_in_map end |
#timestamp ⇒ Object (readonly)
Returns the value of attribute timestamp.
233 234 235 |
# File 'lib/abide_dev_utils/cem/generate/coverage_report.rb', line 233 def @timestamp end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
233 234 235 |
# File 'lib/abide_dev_utils/cem/generate/coverage_report.rb', line 233 def title @title end |
Instance Method Details
#benchmark_hash ⇒ Object
285 286 287 288 289 290 291 |
# File 'lib/abide_dev_utils/cem/generate/coverage_report.rb', line 285 def benchmark_hash { title: @benchmark.title, version: @benchmark.version, framework: @benchmark.framework, } end |
#coverage_hash ⇒ Object
293 294 295 296 297 298 299 300 301 302 303 304 |
# File 'lib/abide_dev_utils/cem/generate/coverage_report.rb', line 293 def coverage_hash { total_count: total_count, uncovered_count: uncovered_count, uncovered: uncovered, covered_count: covered_count, covered: covered, percentage: percentage, controls_in_resource_data: controls_in_resource_data, rules_in_map: rules_in_map, } end |
#covered ⇒ Object
252 253 254 |
# File 'lib/abide_dev_utils/cem/generate/coverage_report.rb', line 252 def covered @covered ||= rules_in_map - uncovered end |
#covered_count ⇒ Object
256 257 258 |
# File 'lib/abide_dev_utils/cem/generate/coverage_report.rb', line 256 def covered_count @covered_count ||= covered.length end |
#percentage ⇒ Object
264 265 266 |
# File 'lib/abide_dev_utils/cem/generate/coverage_report.rb', line 264 def percentage @percentage ||= covered_count.to_f / total_count end |
#to_h ⇒ Object
268 269 270 271 272 273 274 275 |
# File 'lib/abide_dev_utils/cem/generate/coverage_report.rb', line 268 def to_h { title: title, timestamp: , benchmark: benchmark_hash, coverage: coverage_hash, } end |
#to_json(opts = nil) ⇒ Object
277 278 279 |
# File 'lib/abide_dev_utils/cem/generate/coverage_report.rb', line 277 def to_json(opts = nil) JSON.generate(to_h, opts) end |
#to_yaml ⇒ Object
281 282 283 |
# File 'lib/abide_dev_utils/cem/generate/coverage_report.rb', line 281 def to_yaml to_h.to_yaml end |
#total_count ⇒ Object
260 261 262 |
# File 'lib/abide_dev_utils/cem/generate/coverage_report.rb', line 260 def total_count @total_count ||= rules_in_map.length end |
#uncovered ⇒ Object
244 245 246 |
# File 'lib/abide_dev_utils/cem/generate/coverage_report.rb', line 244 def uncovered @uncovered ||= rules_in_map - controls_in_resource_data end |
#uncovered_count ⇒ Object
248 249 250 |
# File 'lib/abide_dev_utils/cem/generate/coverage_report.rb', line 248 def uncovered_count @uncovered_count ||= uncovered.length end |