module CodeRay::PluginHost
def make_plugin_hash
def make_plugin_hash @plugin_map_loaded ||= false Hash.new do |h, plugin_id| id = validate_id(plugin_id) path = path_to id begin raise LoadError, "#{path} not found" unless File.exist? path require path rescue LoadError => boom if @plugin_map_loaded if h.has_key?(:default) warn '%p could not load plugin %p; falling back to %p' % [self, id, h[:default]] h[:default] else raise PluginNotFound, '%p could not load plugin %p: %s' % [self, id, boom] end else load_plugin_map h[plugin_id] end else # Plugin should have registered by now if h.has_key? id h[id] else raise PluginNotFound, "No #{self.name} plugin for #{id.inspect} found in #{path}." end end end end