Sha256: 84e69f52da1a80ba308dd23e9181b66e49c371082a48dbef8f3421bf7cddabc0

Contents?: true

Size: 1.49 KB

Versions: 36

Compression:

Stored size: 1.49 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))

      vmc_gems = Gem.loaded_specs["vmc"]
      ((vmc_gems && vmc_gems.dependencies) || Gem.loaded_specs.values).each do |dep|
        if dep.name =~ /vmc-plugin/
          require "#{dep.name}/plugin"
          enabled.delete dep.name
        end
      end

      # 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|
        begin
          require "#{gemname}/plugin"
        rescue Gem::LoadError => e
          puts "Failed to load #{gemname}:"
          puts "  #{e}"
          puts
          puts "You may need to update or remove this plugin."
          puts
        end
      end
    end
  end
end

Version data entries

36 entries across 36 versions & 4 rubygems

Version Path
cloulu-0.2.6 lib/vmc/plugin.rb
cloulu-0.2.5 lib/vmc/plugin.rb
cloulu-0.2.4 lib/vmc/plugin.rb
cloulu-0.2.3 lib/vmc/plugin.rb
cloulu-0.2.1 lib/vmc/plugin.rb
cloulu-0.2.0 lib/vmc/plugin.rb
cloulu-0.1.6 lib/vmc/plugin.rb
cloulu-0.1.5 lib/vmc/plugin.rb
cloulu-0.1.2 lib/vmc/plugin.rb
cloulu-0.1.1 lib/vmc/plugin.rb
vmc-0.5.1 lib/vmc/plugin.rb
static-1.0.3 vendor/vmc-0.5.0/lib/vmc/plugin.rb
af-0.5.0.beta.11 lib/vmc/plugin.rb
af-0.5.0.beta.10 lib/vmc/plugin.rb
vmc-0.5.1.rc6 lib/vmc/plugin.rb
static-1.0.1 vendor/vmc-0.5.0/lib/vmc/plugin.rb
vmc-0.5.1.rc5 lib/vmc/plugin.rb
vmc-0.5.1.rc4 lib/vmc/plugin.rb
af-0.5.0.beta.9 lib/vmc/plugin.rb
af-0.5.0.beta.8 lib/vmc/plugin.rb