class PluginRegistry

Attributes

registry[R]

Public Class Methods

new() click to toggle source
# File lib/inspec/plugin/v1/registry.rb, line 4
def initialize
  @registry = {}
end

Public Instance Methods

resolve(target, opts = {}) click to toggle source

Resolve a target via available plugins.

@param [String] target to resolve @return [Plugin] plugin instance if it can be resolved, nil otherwise

# File lib/inspec/plugin/v1/registry.rb, line 12
def resolve(target, opts = {})
  modules.each do |m|
    res = if Inspec::Fetcher::Url == m
            m.resolve(target, opts)
          else
            m.resolve(target)
          end
    return res unless res.nil?
  end
  nil
end

Private Instance Methods

modules() click to toggle source

Get all registered plugins sorted by priority, with highest first

@return [Array] sorted list of plugins

# File lib/inspec/plugin/v1/registry.rb, line 29
def modules
  @registry.values
    .sort_by { |x| x.respond_to?(:priority) ? x.priority : 0 }
    .reverse
end