Sha256: 4e2f857e3aa361fd2a26f0fb99b3abd9cf4ed66c5691e44329efe0622be807ef
Contents?: true
Size: 1.49 KB
Versions: 9
Compression:
Stored size: 1.49 KB
Contents
require "set" require "yaml" require "jdc/constants" require "jdc/cli" module JDC module Plugin @@plugins = [] def self.load_all # auto-load gems with 'jdc-plugin' in their name matching = if Gem::Specification.respond_to? :find_all Gem::Specification.find_all do |s| s.name =~ /jdc-plugin/ end else Gem.source_index.find_name(/jdc-plugin/) end enabled = Set.new(matching.collect(&:name)) jdc_gems = Gem.loaded_specs["jdc"] ((jdc_gems && jdc_gems.dependencies) || Gem.loaded_specs.values).each do |dep| if dep.name =~ /jdc-plugin/ require "#{dep.name}/plugin" enabled.delete dep.name end end # allow explicit enabling/disabling of gems via config plugins = File.expand_path(JDC::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 JDC 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
9 entries across 9 versions & 1 rubygems