mirror of
https://github.com/inspec/inspec
synced 2025-02-17 06:28:40 +00:00
Merge pull request #4446 from inspec/zenspider/activated_eh
Rework activator plugin to be more idiomatic.
This commit is contained in:
commit
d96b0a3281
3 changed files with 6 additions and 11 deletions
|
@ -203,8 +203,7 @@ module Inspec
|
|||
|
||||
def _utc_find_credset_name(_credentials, transport_name)
|
||||
return nil unless final_options[:target]
|
||||
|
||||
match = final_options[:target].match(%r{^#{transport_name}://(?<credset_name>[\w\d\-]+)$})
|
||||
match = final_options[:target].match(%r{^#{transport_name}://(?<credset_name>[\w\-]+)$})
|
||||
match ? match[:credset_name] : nil
|
||||
end
|
||||
|
||||
|
|
|
@ -3,21 +3,17 @@ module Inspec::Plugin::V2
|
|||
:plugin_name,
|
||||
:plugin_type,
|
||||
:activator_name,
|
||||
:activated?,
|
||||
:activated,
|
||||
:exception,
|
||||
:activation_proc,
|
||||
:implementation_class
|
||||
) do
|
||||
def initialize(*)
|
||||
super
|
||||
self[:'activated?'] = false
|
||||
self[:activated] = false
|
||||
end
|
||||
|
||||
def activated?(new_value = nil)
|
||||
return self[:activated?] if new_value.nil?
|
||||
|
||||
self[:activated?] = new_value
|
||||
end
|
||||
alias activated? activated
|
||||
|
||||
# Load a plugin, but if an error is encountered, store it and continue
|
||||
def activate
|
||||
|
@ -26,7 +22,7 @@ module Inspec::Plugin::V2
|
|||
# rubocop: disable Lint/RescueException
|
||||
begin
|
||||
impl_class = self[:activation_proc].call
|
||||
self[:activated?] = true
|
||||
self.activated = true
|
||||
self[:implementation_class] = impl_class
|
||||
rescue Exception => ex
|
||||
self[:exception] = ex
|
||||
|
|
|
@ -201,7 +201,7 @@ module Inspec::Plugin::V2
|
|||
status = registry[plugin_name]
|
||||
status.api_generation = 0
|
||||
act = Activator.new
|
||||
act.activated?(true)
|
||||
act.activated = true
|
||||
act.plugin_type = :cli_command
|
||||
act.plugin_name = plugin_name
|
||||
act.activator_name = :default
|
||||
|
|
Loading…
Add table
Reference in a new issue