module KnifeSpork::Plugins

Public Class Methods

klasses() click to toggle source

Get and return a list of all subclasses (plugins) that are not the base plugin

# File lib/knife-spork/plugins.rb, line 21
def self.klasses
  @@klasses ||= self.constants.collect do |c|
    self.const_get(c) if self.const_get(c).is_a?(Class) && self.const_get(c) != KnifeSpork::Plugins::Plugin
  end.compact
end
run(options = {}) click to toggle source
# File lib/knife-spork/plugins.rb, line 6
def self.run(options = {})
  hook = options[:hook].to_sym

  #Load each of the drop-in plugins specified in the custom plugin path
  if (options[:config][:custom_plugin_path] !=nil)
    Dir[File.expand_path("#{options[:config][:custom_plugin_path]}/*.rb")].each { |f| require f }
  end

  klasses.each do |klass|
    plugin = klass.new(options)
    plugin.send(hook) if plugin.respond_to?(hook) && plugin.enabled?
  end
end