From dfb0c922032ddaf9ddf5eb46a883f46715c0a50d Mon Sep 17 00:00:00 2001 From: murphy Date: Mon, 5 Jul 2010 07:26:35 +0000 Subject: Added all_plugins and all_titles methods to Plugin. --- Changes.textile | 2 ++ lib/coderay/helpers/plugin.rb | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/Changes.textile b/Changes.textile index a2bd534..09c7919 100644 --- a/Changes.textile +++ b/Changes.textile @@ -257,6 +257,8 @@ h3. @Plugin@ * *IMPROVED*: @register_for@ sets the @plugin_id@; it can now be a @Symbol@. * *ADDED* @PluginHost#const_missing@ method: Plugins are loaded automatically. Using @Scanners::JavaScript@ in your code loads @scanners/java_script.rb@. +* *ADDED* @#all_plugins@ and @#all_titles@ methods to simplify getting + information about all available plugins (suggested by bnhymn). h3. Internal API changes diff --git a/lib/coderay/helpers/plugin.rb b/lib/coderay/helpers/plugin.rb index ada5ae7..96bfdd6 100644 --- a/lib/coderay/helpers/plugin.rb +++ b/lib/coderay/helpers/plugin.rb @@ -188,6 +188,21 @@ module CodeRay end end + # Returns an array of all Plugins. + # + # Note: This loads all plugins using load_all. + def all_plugins + load_all + plugin_hash.values.grep(Class) + end + + # Returns an array of all plugin titles. + # + # Note: This loads all plugins using load_all. + def all_titles + all_plugins.map { |plugin| plugin.title } + end + # Makes a map of all loaded plugins. def inspect map = plugin_hash.dup -- cgit v1.2.1