Class: Inspec::Deprecation::Deprecator
- Inherits:
-
Object
- Object
- Inspec::Deprecation::Deprecator
- Defined in:
- lib/inspec/utils/deprecation/deprecator.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#fallback_resource_packs ⇒ Object
readonly
Returns the value of attribute fallback_resource_packs.
-
#groups ⇒ Object
readonly
Returns the value of attribute groups.
Instance Method Summary collapse
- #handle_deprecation(group_name, message, opts = {}) ⇒ Object
-
#initialize(opts = {}) ⇒ Deprecator
constructor
A new instance of Deprecator.
-
#match_gem_for_fallback_resource_name(resource_name) ⇒ Object
Given a resource name, suggest a gem nam to load and or install.
Constructor Details
#initialize(opts = {}) ⇒ Deprecator
Returns a new instance of Deprecator.
9 10 11 12 13 |
# File 'lib/inspec/utils/deprecation/deprecator.rb', line 9 def initialize(opts = {}) @config = Inspec::Deprecation::ConfigFile.new(opts[:config_io]) @groups = @config.groups @fallback_resource_packs = @config.fallback_resource_packs end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
7 8 9 |
# File 'lib/inspec/utils/deprecation/deprecator.rb', line 7 def config @config end |
#fallback_resource_packs ⇒ Object (readonly)
Returns the value of attribute fallback_resource_packs.
7 8 9 |
# File 'lib/inspec/utils/deprecation/deprecator.rb', line 7 def fallback_resource_packs @fallback_resource_packs end |
#groups ⇒ Object (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
15 16 17 18 19 20 21 22 23 |
# File 'lib/inspec/utils/deprecation/deprecator.rb', line 15 def handle_deprecation(group_name, , opts = {}) group = groups[group_name.to_sym] || create_group_entry_for_unknown_group(group_name) annotate_stack_information(opts) = (, group, opts) action = group[:action] || :warn action_method = ("handle_" + action.to_s + "_action").to_sym send(action_method, group_name.to_sym, , group) end |
#match_gem_for_fallback_resource_name(resource_name) ⇒ Object
Given a resource name, suggest a gem nam to load and or install
26 27 28 29 30 |
# File 'lib/inspec/utils/deprecation/deprecator.rb', line 26 def match_gem_for_fallback_resource_name(resource_name) fallback = fallback_resource_packs.find { |fb| fb.resource_name_regex.match(resource_name) } # We have a message here but can't pass it back? fallback&.gem_name end |