Class: Inspec::Deprecation::Deprecator

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Deprecator

Returns a new instance of Deprecator.



9
10
11
12
# File 'lib/inspec/utils/deprecation/deprecator.rb', line 9

def initialize(opts = {})
  @config = Inspec::Deprecation::ConfigFile.new(opts[:config_io])
  @groups = @config.groups
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



7
8
9
# File 'lib/inspec/utils/deprecation/deprecator.rb', line 7

def config
  @config
end

#groupsObject (readonly)

Returns the value of attribute groups.



7
8
9
# File 'lib/inspec/utils/deprecation/deprecator.rb', line 7

def groups
  @groups
end

Instance Method Details

#handle_deprecation(group_name, message, opts = {}) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/inspec/utils/deprecation/deprecator.rb', line 14

def handle_deprecation(group_name, message, opts = {})
  group = groups[group_name.to_sym] || create_group_entry_for_unknown_group(group_name)
  annotate_stack_information(opts)
  assembled_message = assemble_message(message, group, opts)

  action = group[:action] || :warn
  action_method = ("handle_" + action.to_s + "_action").to_sym
  send(action_method, group_name.to_sym, assembled_message, group)
end