Module Webgen::PluginDefs::ClassMethods
In: lib/webgen/plugin.rb
RuntimeError PluginParamNotFound PluginNotFound ConfigurationFileInvalid CmdParse::CommandParser CommandParser DirectoryInfo GalleryStyle WebSiteStyle WebSiteTemplate SipttraStyle Test::Unit::TestCase TestCase PluginTestCase TagTestCase CmdParse::Command ShowCommand CheckCommand UseCommand CreateCommand TSort DependencyHash Hash Comparable Language ::Logger Logger Logger DEFAULT_WRAPPER_MODULE WebSite Qt::MainWindow MainWindow Qt::Dialog NewWebsiteDialog Qt::TextEdit LogWidget ::Rake::TaskLib WebgenTask ConfigurationFile Website PluginManager PluginLoader PluginParamValueNotFound Dummy Color CliUtils PluginDefs lib/webgen/languages.rb lib/webgen/website.rb lib/webgen/gui/common.rb lib/webgen/plugin.rb lib/webgen/test.rb lib/webgen/cli.rb ClassMethods PluginDefs LanguageManager lib/webgen/gui/new_website_dlg.rb lib/webgen/gui/main.rb GUI lib/webgen/rake/webgentask.rb Rake Webgen dot/m_60_1.png

All the methods of this module become class methods in the classes which include the PluginDefs module.

Methods

Public Class methods

Called when PluginDefs is included in another class. Add this class to plugin data.

[Source]

    # File lib/webgen/plugin.rb, line 52
52:       def self.extended( klass )
53:         callcc {|cont| throw :plugin_class_found, [cont, klass]}
54:         klass.init_config
55:       rescue NameError => e
56:         raise "Plugin '#{klass}' managed by no PluginLoader"
57:       end

Public Instance methods

Returns the ancestor classes for the object‘s class which are not base plugins.

[Source]

     # File lib/webgen/plugin.rb, line 112
112:       def ancestor_classes
113:         ancestors.delete_if {|c| c.instance_of?( Module ) ||
114:           (c.respond_to?( :config ) && c.config.infos[:is_base_plugin] == true) }[0..-2]
115:       end

Returns the configuration structure for the plugin.

[Source]

    # File lib/webgen/plugin.rb, line 70
70:       def config
71:         @config
72:       end

Add a dependency to the plugin, ie. the name of another plugin. Dependencies are instantiated before the plugin gets instantiated. So only add those plugins here that you need to reference/use in the initialize method! The parameters have to be Strings!

[Source]

    # File lib/webgen/plugin.rb, line 96
96:       def depends_on( *dep )
97:         dep.each {|d| self.config.dependencies << d}
98:       end

Sets general information about the plugin (summary text, description, …). The parameter has to be a Hash. The following fields are recognized:

:name :The name of the plugin. Should be of the form Namespace/Namespace/name and should contain only alphanumeric characters.
:summary :Summary of what the plugin does
:description :Extended description of the functionality
:author :The author of the plugin
:instantiate :Boolean value defining whether an instance of this plugin should be created
:is_base_plugin :Boolean value defining whether the plugin class is available from a plugin loader/manager after loading

[Source]

    # File lib/webgen/plugin.rb, line 89
89:       def infos( param )
90:         self.config.infos.update( param )
91:       end

Add subclass to plugin data.

[Source]

    # File lib/webgen/plugin.rb, line 47
47:       def inherited( klass )
48:         ClassMethods.extended( klass )
49:       end

Initializes the plugin configuration structure.

[Source]

    # File lib/webgen/plugin.rb, line 60
60:       def init_config
61:         @config = OpenStruct.new
62:         @config.plugin_klass = self
63:         @config.params = {}
64:         @config.infos = {}
65:         @config.infos[:name] = self.name.sub(/^(#<.*?>|Webgen::DEFAULT_WRAPPER_MODULE)::/,'').sub('::','/')
66:         @config.dependencies = []
67:       end

Defines a parameter.The parameter can be changed in the configuration file later.

Arguments:

name:the name of the parameter
default:the default value of the parameter
description:a small description of the parameter

[Source]

     # File lib/webgen/plugin.rb, line 106
106:       def param( name, default, description )
107:         data = OpenStruct.new( :name => name, :default => default, :description => description )
108:         self.config.params[name] = data
109:       end

Returns the name of the plugin. If not plugin name is set a default value is used.

[Source]

    # File lib/webgen/plugin.rb, line 75
75:       def plugin_name
76:         @config.infos[:name]
77:       end

[Validate]