class Chef::Compliance::Waiver
Chef
object that represents a single waiver file in the compliance segment of a cookbook
Constants
- HIDDEN_IVARS
Attributes
@return [String] The name of the cookbook that the waiver is in
@api private
@return [Boolean] if the waiver has been enabled
Event dispatcher for this run.
@return [Chef::EventDispatch::Dispatcher]
@return [String] The full path on the host to the waiver yml file
@return [String] the pathname in the cookbook
Public Class Methods
Source
# File lib/chef/compliance/waiver.rb, line 110 def self.from_file(events, filename, cookbook_name = nil) from_yaml(events, IO.read(filename), filename, cookbook_name) end
@param filename [String] full path to the yml file in the cookbook @param cookbook_name
[String] cookbook that the waiver is in
Source
# File lib/chef/compliance/waiver.rb, line 96 def self.from_hash(events, hash, path = nil, cookbook_name = nil) new(events, hash, path, cookbook_name) end
Helper to construct a waiver object from a hash. Since the path and cookbook_name
are required this is probably not externally useful.
Source
# File lib/chef/compliance/waiver.rb, line 103 def self.from_yaml(events, string, path = nil, cookbook_name = nil) from_hash(events, YAML.safe_load(string, permitted_classes: [Date]), path, cookbook_name) end
Helper to construct a waiver object from a yaml string. Since the path and cookbook_name
are required this is probably not externally useful.
Source
# File lib/chef/compliance/waiver.rb, line 48 def initialize(events, data, path, cookbook_name) @events = events @data = data @cookbook_name = cookbook_name @path = path @pathname = File.basename(path, File.extname(path)) unless path.nil? disable! end
Public Instance Methods
Source
# File lib/chef/compliance/waiver.rb, line 72 def disable! @enabled = false end
Set the waiver as being disabled
Source
# File lib/chef/compliance/waiver.rb, line 65 def enable! events.compliance_waiver_enabled(self) @enabled = true end
Set the waiver to being enabled
Source
# File lib/chef/compliance/waiver.rb, line 59 def enabled? !!@enabled end
@return [Boolean] if the waiver has been enabled
Source
# File lib/chef/compliance/waiver.rb, line 78 def inspec_data data end
Render the waiver in a way that it can be consumed by inspec
Source
# File lib/chef/compliance/waiver.rb, line 86 def inspect ivar_string = (instance_variables.map(&:to_sym) - HIDDEN_IVARS).map do |ivar| "#{ivar}=#{instance_variable_get(ivar).inspect}" end.join(", ") "#<#{self.class}:#{object_id} #{ivar_string}>" end
Omit the event object from error output