Class: PluginRegistry

Inherits:
Object
  • Object
show all
Defined in:
lib/inspec/plugin/v1/registry.rb,
lib/inspec/plugin/v1/registry.rb

Defined Under Namespace

Classes: Plugin

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePluginRegistry

Returns a new instance of PluginRegistry.



4
5
6
# File 'lib/inspec/plugin/v1/registry.rb', line 4

def initialize
  @registry = {}
end

Instance Attribute Details

#registryObject (readonly)

Returns the value of attribute registry.



2
3
4
# File 'lib/inspec/plugin/v1/registry.rb', line 2

def registry
  @registry
end

Instance Method Details

#resolve(target, opts = {}) ⇒ Plugin

Resolve a target via available plugins.

Parameters:

  • target (String)

    to resolve

Returns:

  • (Plugin)

    plugin instance if it can be resolved, nil otherwise



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/inspec/plugin/v1/registry.rb', line 12

def resolve(target, opts = {})
  modules.each do |m|
    res = if ["Inspec::Fetcher::Url", "Supermarket::Fetcher"].include? m.to_s
            m.resolve(target, opts)
          else
            m.resolve(target)
          end
    return res unless res.nil?
  end
  nil
end