Class: Inspec::Deprecation::ConfigFile

Inherits:
Object
  • Object
show all
Defined in:
lib/inspec/utils/deprecation/config_file.rb

Defined Under Namespace

Classes: GroupEntry

Constant Summary collapse

VALID_ACTIONS =

What actions may you specify to be taken when a deprecation is encountered?

[
  :exit, # Hard exit `inspec`, no stacktrace, exit code specified or Inspec::UI::EXIT_FATAL_DEPRECATION
  :fail_control, # Fail the control with a message. If not in a control, do :warn action instead.
  :ignore, # Do nothing.
  :warn, # Issue a warning
].freeze
VALID_GROUP_FIELDS =

Note that ‘comment’ is ignored, but listed here so you can have it present and pass validation.

%w{action suffix prefix exit_status comment}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(io = nil) ⇒ ConfigFile

Returns a new instance of ConfigFile.



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/inspec/utils/deprecation/config_file.rb', line 25

def initialize(io = nil)
  io ||= open_default_config_io
  begin
    @raw_data = JSON.parse(io.read)
  rescue JSON::ParserError => e
    raise Inspec::Deprecation::MalformedConfigFileError, "Could not parse deprecation config file: #{e.message}"
  end

  @groups = {}
  @unknown_group_action = :warn
  validate!
  silence_deprecations_from_cli
end

Instance Attribute Details

#groupsObject (readonly)

Returns the value of attribute groups.



23
24
25
# File 'lib/inspec/utils/deprecation/config_file.rb', line 23

def groups
  @groups
end

#unknown_group_actionObject (readonly)

Returns the value of attribute unknown_group_action.



23
24
25
# File 'lib/inspec/utils/deprecation/config_file.rb', line 23

def unknown_group_action
  @unknown_group_action
end