summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormurphy <murphy@rubychan.de>2010-07-05 07:26:35 +0000
committermurphy <murphy@rubychan.de>2010-07-05 07:26:35 +0000
commitdfb0c922032ddaf9ddf5eb46a883f46715c0a50d (patch)
treea953f3312d0fbfa551f036cec1fe7a2d830472ef
parent6ce02e0b6c6f1d6ee0a225df6832205b95ad93e9 (diff)
downloadcoderay-dfb0c922032ddaf9ddf5eb46a883f46715c0a50d.tar.gz
Added all_plugins and all_titles methods to Plugin.
-rw-r--r--Changes.textile2
-rw-r--r--lib/coderay/helpers/plugin.rb15
2 files changed, 17 insertions, 0 deletions
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