Module: CF::Plugin

Defined in:
lib/cf/plugin.rb

Constant Summary collapse

@@plugins =
[]

Class Method Summary collapse

Class Method Details

.load_allObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/cf/plugin.rb', line 11

def self.load_all
  # auto-load gems with 'vmc-plugin' in their name
  enabled =
    Set.new(
      Gem::Specification.find_all { |s|
        s.name =~ /vmc-plugin/
      }.collect(&:name))

  # allow explicit enabling/disabling of gems via config
  plugins = File.expand_path(CF::PLUGINS_FILE)
  if File.exists?(plugins) && yaml = YAML.load_file(plugins)
    enabled += yaml["enabled"] if yaml["enabled"]
    enabled -= yaml["disabled"] if yaml["disabled"]
  end

  # load up each gem's 'plugin' file
  #
  # we require this file specifically so people can require the gem
  # without it plugging into CF
  enabled.each do |gemname|
    require "#{gemname}/plugin"
  end
end