Class: AbideDevUtils::Comply::NodeScanReport

Inherits:
Object
  • Object
show all
Defined in:
lib/abide_dev_utils/comply.rb

Overview

Class representation of a Comply node scan report

Constant Summary collapse

DIFF_PROPERTIES =
%i[passing failing error not_checked informational].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(node_name, node_hash) ⇒ NodeScanReport

Returns a new instance of NodeScanReport.



467
468
469
470
471
472
473
474
475
476
477
478
479
# File 'lib/abide_dev_utils/comply.rb', line 467

def initialize(node_name, node_hash)
  @name = node_name
  @hash = node_hash
  @passing = node_hash.dig('scan_results', 'Pass') || {}
  @failing = node_hash.dig('scan_results', 'Fail') || {}
  @error = node_hash.dig('scan_results', 'Error') || {}
  @not_checked = node_hash.dig('scan_results', 'Not checked') || {}
  @informational = node_hash.dig('scan_results', 'Informational') || {}
  @benchmark = node_hash['benchmark']
  @last_scan = node_hash['last_scan']
  @profile = node_hash.fetch('custom_profile', nil) || node_hash.fetch('profile', nil)
  create_equality_methods
end

Instance Attribute Details

#benchmarkObject (readonly)

Returns the value of attribute benchmark.



463
464
465
# File 'lib/abide_dev_utils/comply.rb', line 463

def benchmark
  @benchmark
end

#errorObject (readonly)

Returns the value of attribute error.



463
464
465
# File 'lib/abide_dev_utils/comply.rb', line 463

def error
  @error
end

#failingObject (readonly)

Returns the value of attribute failing.



463
464
465
# File 'lib/abide_dev_utils/comply.rb', line 463

def failing
  @failing
end

#informationalObject (readonly)

Returns the value of attribute informational.



463
464
465
# File 'lib/abide_dev_utils/comply.rb', line 463

def informational
  @informational
end

#last_scanObject (readonly)

Returns the value of attribute last_scan.



463
464
465
# File 'lib/abide_dev_utils/comply.rb', line 463

def last_scan
  @last_scan
end

#nameObject (readonly)

Returns the value of attribute name.



463
464
465
# File 'lib/abide_dev_utils/comply.rb', line 463

def name
  @name
end

#not_checkedObject (readonly)

Returns the value of attribute not_checked.



463
464
465
# File 'lib/abide_dev_utils/comply.rb', line 463

def not_checked
  @not_checked
end

#passingObject (readonly)

Returns the value of attribute passing.



463
464
465
# File 'lib/abide_dev_utils/comply.rb', line 463

def passing
  @passing
end

#profileObject (readonly)

Returns the value of attribute profile.



463
464
465
# File 'lib/abide_dev_utils/comply.rb', line 463

def profile
  @profile
end

Instance Method Details

#diff(other) ⇒ Object



481
482
483
484
485
486
487
# File 'lib/abide_dev_utils/comply.rb', line 481

def diff(other)
  diff = {}
  DIFF_PROPERTIES.each do |prop|
    diff[prop] = send("#{prop.to_s}_equal?".to_sym, other.send(prop)) ? {} : property_diff(prop, other)
  end
  diff
end