Class: Chef::Audit::ControlGroupData
- Inherits:
-
Object
- Object
- Chef::Audit::ControlGroupData
- Defined in:
- lib/chef/audit/control_group_data.rb
Instance Attribute Summary collapse
-
#controls ⇒ Object
readonly
Returns the value of attribute controls.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#number_failed ⇒ Object
readonly
Returns the value of attribute number_failed.
-
#number_succeeded ⇒ Object
readonly
Returns the value of attribute number_succeeded.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
- #example_failure(control_data, details) ⇒ Object
- #example_success(control_data) ⇒ Object
-
#initialize(name, metadata = {}) ⇒ ControlGroupData
constructor
A new instance of ControlGroupData.
- #to_hash ⇒ Object
Constructor Details
#initialize(name, metadata = {}) ⇒ ControlGroupData
Returns a new instance of ControlGroupData.
52 53 54 55 56 57 58 59 |
# File 'lib/chef/audit/control_group_data.rb', line 52 def initialize(name, = {}) @status = "success" @controls = [] @number_succeeded = 0 @number_failed = 0 @name = name @metadata = end |
Instance Attribute Details
#controls ⇒ Object (readonly)
Returns the value of attribute controls.
50 51 52 |
# File 'lib/chef/audit/control_group_data.rb', line 50 def controls @controls end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
50 51 52 |
# File 'lib/chef/audit/control_group_data.rb', line 50 def @metadata end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
50 51 52 |
# File 'lib/chef/audit/control_group_data.rb', line 50 def name @name end |
#number_failed ⇒ Object (readonly)
Returns the value of attribute number_failed.
50 51 52 |
# File 'lib/chef/audit/control_group_data.rb', line 50 def number_failed @number_failed end |
#number_succeeded ⇒ Object (readonly)
Returns the value of attribute number_succeeded.
50 51 52 |
# File 'lib/chef/audit/control_group_data.rb', line 50 def number_succeeded @number_succeeded end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
50 51 52 |
# File 'lib/chef/audit/control_group_data.rb', line 50 def status @status end |
Instance Method Details
#example_failure(control_data, details) ⇒ Object
69 70 71 72 73 74 75 76 77 |
# File 'lib/chef/audit/control_group_data.rb', line 69 def example_failure(control_data, details) @number_failed += 1 @status = "failure" control = create_control(control_data) control.details = details if details control.status = "failure" controls << control control end |
#example_success(control_data) ⇒ Object
61 62 63 64 65 66 67 |
# File 'lib/chef/audit/control_group_data.rb', line 61 def example_success(control_data) @number_succeeded += 1 control = create_control(control_data) control.status = "success" controls << control control end |
#to_hash ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/chef/audit/control_group_data.rb', line 79 def to_hash # We sort it so the examples appear in the output in the same order # they appeared in the recipe controls.sort! { |x, y| x.line_number <=> y.line_number } h = { :name => name, :status => status, :number_succeeded => number_succeeded, :number_failed => number_failed, :controls => controls.collect { |c| c.to_hash }, } # If there is a duplicate key, metadata will overwrite it add_display_only_data(h).merge() end |