Method: Kitchen::Plugin.plugins_available

Defined in:
lib/kitchen/plugin.rb

.plugins_available(plugin_type) ⇒ Array<String>

given a type of plugin, searches the Ruby load path for plugins of that type based on the path+naming convention that plugin loading is based upon

Parameters:

  • plugin_type (String)

    the name of a plugin type (e.g. driver, provisioner, transport, verifier)

Returns:

  • (Array<String>)

    a collection of Ruby filenames that are probably plugins of the given type



65
66
67
68
69
70
71
72
73
74
# File 'lib/kitchen/plugin.rb', line 65

def self.plugins_available(plugin_type)
  $LOAD_PATH.map { |load_path| Dir[File.expand_path("kitchen/#{plugin_type}/*.rb", load_path)] }
    .reject(&:empty?)
    .flatten
    .uniq
    .select { |plugin_path| File.readlines(plugin_path).grep(/^\s*class \w* </).any? }
    .map { |plugin_path| File.basename(plugin_path).gsub(/\.rb$/, "") }
    .reject { |plugin_name| plugin_name == "base" }
    .sort
end