mirror of
https://github.com/inspec/inspec
synced 2025-02-17 06:28:40 +00:00
Add valid_plugin_name? predicate and push exclusion list check into its own method
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
This commit is contained in:
parent
16fecbefb5
commit
3cd6eee016
2 changed files with 13 additions and 4 deletions
|
@ -63,11 +63,19 @@ module Inspec::Plugin::V2
|
|||
|
||||
module FilterPredicates
|
||||
def train_plugin_name?(name)
|
||||
name.to_s.start_with?("train-") && ! Inspec::Plugin::V2::PluginFilter.exclude?(name)
|
||||
name.to_s.start_with?("train-") && name_allowed?(name)
|
||||
end
|
||||
|
||||
def inspec_plugin_name?(name)
|
||||
name.to_s.start_with?("inspec-") && ! Inspec::Plugin::V2::PluginFilter.exclude?(name)
|
||||
name.to_s.start_with?("inspec-") && name_allowed?(name)
|
||||
end
|
||||
|
||||
def valid_plugin_name?(name)
|
||||
name.to_s.match(/^(inspec|train)-/) && name_allowed?(name)
|
||||
end
|
||||
|
||||
def name_allowed?(name)
|
||||
! Inspec::Plugin::V2::PluginFilter.exclude?(name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -137,10 +137,11 @@ module Inspec::Plugin::V2
|
|||
end
|
||||
|
||||
# Lists all plugin gems found in the plugin_gem_path.
|
||||
# This is simply all gems that begin with train- or inspec-.
|
||||
# This is simply all gems that begin with train- or inspec-
|
||||
# and are not on the exclusion list.
|
||||
# @return [Array[Gem::Specification]] Specs of all gems found.
|
||||
def self.list_installed_plugin_gems
|
||||
list_managed_gems.select { |spec| inspec_plugin_name?(spec.name) || train_plugin_name?(spec.name) }
|
||||
list_managed_gems.select { |spec| valid_plugin_name?(spec.name) }
|
||||
end
|
||||
|
||||
def list_installed_plugin_gems
|
||||
|
|
Loading…
Add table
Reference in a new issue