11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/jdc/plugin.rb', line 11
def self.load_all
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
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
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
|