52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
# File 'lib/markdown_server/plugin.rb', line 52
def load_plugins(root_dir, cli_overrides = {}, plugin_dirs: [])
plugin_dirs.each do |dir|
expanded = File.expand_path(dir)
Dir[File.join(expanded, "*", "plugin.rb")].sort.each { |f| require f }
end
config = resolve_config(root_dir, cli_overrides)
known_names = registered.map(&:plugin_name)
config.each do |name, cfg|
next unless cfg.is_a?(Hash) && cfg["enabled"]
unless known_names.include?(name)
$stderr.puts "\n\e[1;33mWarning: unknown plugin '#{name}' (available: #{known_names.join(", ")})\e[0m\n\n"
end
end
registered.filter_map do |klass|
plugin_config = config.fetch(klass.plugin_name, {})
enabled = plugin_config.fetch("enabled", klass.enabled_by_default?)
next unless enabled
klass.new.tap { |p| p.setup(plugin_config) }
end
end
|