Sha256: cf1c707992cfeee8c1f856fe67b282590bbf3fe5eae55f891869796bbce94c7f

Contents?: true

Size: 996 Bytes

Versions: 11

Compression:

Stored size: 996 Bytes

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
      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(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

  def self.Plugin(target = CLI, &blk)
    # SUPER FANCY PLUGIN SYSTEM
    target.class_eval &blk
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
vmc-0.4.0.beta.12 vmc-ng/lib/vmc/plugin.rb
vmc-0.4.0.beta.11 vmc-ng/lib/vmc/plugin.rb
vmc-0.4.0.beta.10 vmc-ng/lib/vmc/plugin.rb
vmc-0.4.0.beta.9 lib/vmc/plugin.rb
vmc-0.4.0.beta.8 vmc-ng/lib/vmc/plugin.rb
vmc-0.4.0.beta.7 vmc-ng/lib/vmc/plugin.rb
vmc-0.4.0.beta.6 lib/vmc/plugin.rb
vmc-0.4.0.beta.5 vmc-ng/lib/vmc/plugin.rb
vmc-0.4.0.beta.3 vmc-ng/lib/vmc/plugin.rb
vmc-0.4.0.beta.2 vmc-ng/lib/vmc/plugin.rb
vmc-0.4.0.beta.1 vmc-ng/lib/vmc/plugin.rb