Class: AbideDevUtils::Comply::ScanReport
- Inherits:
-
Object
- Object
- AbideDevUtils::Comply::ScanReport
- Defined in:
- lib/abide_dev_utils/comply.rb
Overview
Contains multiple NodeScanReport objects
Instance Attribute Summary collapse
-
#node_scan_reports ⇒ Object
readonly
Returns the value of attribute node_scan_reports.
Class Method Summary collapse
- .fetch_report(name: 'comply_report.yaml') ⇒ Object
- .storage_bucket ⇒ Object
- .upload_report(report, name: 'comply_report.yaml') ⇒ Object
Instance Method Summary collapse
- #from_yaml(report) ⇒ Object
- #good_comparison?(report_comparison) ⇒ Boolean
- #report_comparison(other, check_goodness: false) ⇒ Object
- #to_h ⇒ Object
- #to_yaml ⇒ Object
Instance Attribute Details
#node_scan_reports ⇒ Object (readonly)
Returns the value of attribute node_scan_reports.
377 378 379 |
# File 'lib/abide_dev_utils/comply.rb', line 377 def node_scan_reports @node_scan_reports end |
Class Method Details
.fetch_report(name: 'comply_report.yaml') ⇒ Object
405 406 407 408 |
# File 'lib/abide_dev_utils/comply.rb', line 405 def self.fetch_report(name: 'comply_report.yaml') report = storage_bucket.file(name) report.download.read end |
.storage_bucket ⇒ Object
401 402 403 |
# File 'lib/abide_dev_utils/comply.rb', line 401 def self.storage_bucket @storage_bucket ||= AbideDevUtils::GCloud.storage_bucket end |
.upload_report(report, name: 'comply_report.yaml') ⇒ Object
410 411 412 |
# File 'lib/abide_dev_utils/comply.rb', line 410 def self.upload_report(report, name: 'comply_report.yaml') storage_bucket.create_file(report, name) end |
Instance Method Details
#from_yaml(report) ⇒ Object
379 380 381 382 383 384 385 386 387 388 389 |
# File 'lib/abide_dev_utils/comply.rb', line 379 def from_yaml(report) @scan_report = if report.is_a? Hash report elsif File.file?(report) File.open(report.to_s, 'r') { |f| YAML.safe_load(f.read) } else YAML.safe_load(report) end @node_scan_reports = build_node_scan_reports self end |
#good_comparison?(report_comparison) ⇒ Boolean
427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 |
# File 'lib/abide_dev_utils/comply.rb', line 427 def good_comparison?(report_comparison) good = true not_good = {} report_comparison.each do |node_report| node_name = node_report.keys[0] report = node_report[node_name] next if report[:diff].empty? not_good[node_name] = {} unless report.dig(:diff, :passing, :other).nil? good = false not_good[node_name][:new_not_passing] = report[:diff][:passing][:other] end unless report.dig(:diff, :failing, :self).nil? good = false not_good[node_name][:new_failing] = report[:diff][:failing][:self] end end [good, not_good] end |
#report_comparison(other, check_goodness: false) ⇒ Object
414 415 416 417 418 419 420 421 422 423 424 425 |
# File 'lib/abide_dev_utils/comply.rb', line 414 def report_comparison(other, check_goodness: false) comparison = [] node_scan_reports.zip(other.node_scan_reports).each do |cr, lr| comparison << { cr.name => { diff: {}, node_presense: :new } } if lr.nil? comparison << { lr.name => { diff: {}, node_presense: :dropped } } if cr.nil? comparison << { cr.name => { diff: cr.diff(lr), node_presence: :same } } unless cr.nil? || lr.nil? end comparison.inject(&:merge) return good_comparison?(comparison) if check_goodness compairison end |
#to_h ⇒ Object
391 392 393 394 395 |
# File 'lib/abide_dev_utils/comply.rb', line 391 def to_h node_scan_reports.each_with_object({}) do |node, h| h[node.name] = node.hash end end |
#to_yaml ⇒ Object
397 398 399 |
# File 'lib/abide_dev_utils/comply.rb', line 397 def to_yaml to_h.to_yaml end |