Sha256: e71687b9658e84322caba1d1dbaf9f3b86beb0d4dd5c1399c906bd5475f0e2e9

Contents?: true

Size: 1.02 KB

Versions: 6

Compression:

Stored size: 1.02 KB

Contents

require "set"
require "yaml"

require "vmc/constants"
require "vmc/cli"

module VMC
  module Plugin
    @@plugins = []

    def self.load_all
      # auto-load gems with 'vmc-plugin' in their name
      matching =
        if Gem::Specification.respond_to? :find_all
          Gem::Specification.find_all do |s|
            s.name =~ /vmc-plugin/
          end
        else
          Gem.source_index.find_name(/vmc-plugin/)
        end

      enabled = Set.new(matching.collect(&:name))

      # allow explicit enabling/disabling of gems via config
      plugins = File.expand_path(VMC::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 VMC
      enabled.each do |gemname|
        require "#{gemname}/plugin"
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
vmc-0.4.0.beta.36 vmc-ng/lib/vmc/plugin.rb
vmc-0.4.0.beta.35 vmc-ng/lib/vmc/plugin.rb
vmc-0.4.0.beta.34 vmc-ng/lib/vmc/plugin.rb
vmc-0.4.0.beta.33 vmc-ng/lib/vmc/plugin.rb
vmc-0.4.0.beta.32 vmc-ng/lib/vmc/plugin.rb
vmc-0.4.0.beta.31 vmc-ng/lib/vmc/plugin.rb