Merge pull request #4446 from inspec/zenspider/activated_eh

Rework activator plugin to be more idiomatic.
This commit is contained in:
Miah Johnson 2019-09-06 11:57:31 -07:00 committed by GitHub
commit d96b0a3281
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 11 deletions

View file

@ -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

View file

@ -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

View file

@ -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