mirror of
https://github.com/inspec/inspec
synced 2024-11-22 12:43:07 +00:00
bugfix - plugin_name is called from both plugin definition and implementation classes
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
This commit is contained in:
parent
53beaff372
commit
a62fdabf70
1 changed files with 14 additions and 1 deletions
|
@ -57,6 +57,13 @@ module Inspec::Plugin::V2
|
|||
@@plugin_type_classes[plugin_type_name]
|
||||
end
|
||||
|
||||
def self.find_type_by_implementation_class(impl_class)
|
||||
# This is super awkward
|
||||
activators = Inspec::Plugin::V2::Registry.instance.find_activators
|
||||
activator = activators.detect { |a| a.implementation_class == impl_class }
|
||||
activator.plugin_name
|
||||
end
|
||||
|
||||
#=====================================================================#
|
||||
# DSL Methods
|
||||
#=====================================================================#
|
||||
|
@ -71,7 +78,13 @@ module Inspec::Plugin::V2
|
|||
# @returns [Symbol] Name of the plugin
|
||||
def self.plugin_name(name = nil)
|
||||
reg = Inspec::Plugin::V2::Registry.instance
|
||||
return reg.find_status_by_class(self).name if name.nil?
|
||||
if name.nil?
|
||||
# If called from a Plugin definition class...
|
||||
stat = reg.find_status_by_class(self)
|
||||
return stat.name if stat
|
||||
# Called from an implementation class
|
||||
return find_type_by_implementation_class(self)
|
||||
end
|
||||
|
||||
name = name.to_sym
|
||||
|
||||
|
|
Loading…
Reference in a new issue