Module: Doing::Plugins

Defined in:
lib/doing/plugin_manager.rb

Overview

Plugin handling

Class Method Summary collapse

Class Method Details

.available_plugins(type: :export) ⇒ Array

Return array of available plugin names

Parameters:

  • type (Symbol) (defaults to: :export)

    Plugin type (:import, :export)

Returns:

  • (Array)

    Array of plugin names (String)

.list_plugins(options = {}) ⇒ Object

List available plugins to stdout

Parameters:

  • options (Hash) (defaults to: {})

    additional options

Options Hash (options):

  • :column (Boolean)

    display results in a single column

  • :type (String)

    Plugin type: all, import, or export

.load_plugins(add_dir = nil) ⇒ Object

Load plugins from plugins folder

.plugin_names(type: :export, separator: '|') ⇒ String

Return string version of plugin names

Parameters:

  • type (defaults to: :export)

    Plugin type (:import, :export)

  • separator (defaults to: '|')

    The separator to join names with

Returns:

  • (String)

    Plugin names joined with separator

.plugin_regex(type: :export) ⇒ Regexp

Return a regular expression of all plugin triggers for type

Parameters:

  • type (Symbol) (defaults to: :export)

    The type :import or :export

Returns:

  • (Regexp)

    regular expression

.plugin_templates(type: :export) ⇒ Array

Return array of available template names

Parameters:

  • type (Symbol) (defaults to: :export)

    Plugin type (:import, :export)

Returns:

  • (Array)

    Array of template names (String)

.pluginsHash

Storage for registered plugins. Hash with :import and :export keys containing hashes of available plugins.

Returns:

  • (Hash)

    registered plugins

.plugins_path(add_dir = nil) ⇒ Array

Setup the plugin search path

Parameters:

  • add_dir (String) (defaults to: nil)

    optional additional path to include

Returns:

  • (Array)

    Returns an Array of plugin search paths

.register(title, type, klass) ⇒ Boolean

Register a plugin

Parameters:

  • title (String|Array)

    The name of the plugin (can be an array of names)

  • type (Symbol)

    The plugin type (:import, :export)

  • klass (Class)

    The class responding to :render or :import

Returns:

  • (Boolean)

    Success boolean

.template_for_trigger(trigger, type: :export, save_to: nil) ⇒ String

Find and return the appropriate template for a trigger string. Outputs a string that can be written out to the terminal for redirection

Parameters:

  • trigger (String)

    The trigger to test

  • type (Symbol) (defaults to: :export)

    the plugin type (:import, :export)

  • save_to (String) (defaults to: nil)

    if a path is specified, write the template to that path. Nil for STDOUT

Returns:

  • (String)

    string content of template for trigger

Raises:

.template_regex(type: :export) ⇒ Regexp

Return a regular expression of all template triggers for type

Parameters:

  • type (Symbol) (defaults to: :export)

    The type :import or :export

Returns:

  • (Regexp)

    regular expression

.user_homeObject

Return the user's home directory

.valid_type(type, default: nil) ⇒ Symbol

Converts a partial symbol to a valid plugin type, e.g. :imp => :import

Parameters:

  • type (Symbol)

    the symbol to test

  • default (Symbol) (defaults to: nil)

    fallback value

Returns:

  • (Symbol)

    :import or :export

.validate_plugin(title, type, klass) ⇒ Object

Verifies that a plugin is properly configured with necessary methods for its type. If the plugin fails validation, a PluginUncallable exception will be raised.

Parameters:

  • title (String)

    The title

  • type (Symbol)

    type, :import or :export

  • klass (Class)

    Plugin class