Sha256: e369d348ab71f9dfcfe29eff226862de70b563607d8c901262bd9fb46e76fc76

Contents?: true

Size: 1.45 KB

Versions: 2

Compression:

Stored size: 1.45 KB

Contents

# Amp Frontend Plugin Design Doc

This document intends to specify how plugins will be managed by the generic
Amp front-end.

## Amp::Plugin Subclasses

By tracking the subclasses (and subclasses of subclasses) of Amp::Plugin, we
can look up all plugins that are loaded. Thus, to register a plugin, one simply
needs to load a Ruby file that contains the definition of an Amp::Plugin subclass.

The list of all plugins can be retrieved with the following Ruby code:

    Amp::Plugin.all_plugins

Which is simply an accessor to an ivar on the Amp::Plugin metaclass. Following
the Ruby convention of preferring convention over configuration, the default
Ampfile contains the following, single statement:

    Amp::Plugin.load_rubygems_plugins

which, when run, all gems are searched for the file 'amp/plugin.rb'. All such files
are loaded in an arbitrary order.

If a plugin is automatically loaded that you *do not* wish to be loaded, you
will have to require each one individually. You do not need to manually load
amp-core. amp-core will be loaded first.

## Plugin Callbacks

Each plugin class in `Amp::Plugin.all_plugins` is instantiated with the current
global configuration as the sole parameter:

    class Amp::Plugin::Git < Amp::Plugin::Base
      def initialize(settings)
        puts "oh noez" if settings[:failboatz]
      end
    end
    
Or the simpler:

    amp_plugin 'git' do
      init do |settings|
        puts "oh noez" if settings[:failboatz]
      end
    end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
amp-front-0.2.0 design_docs/plugins.md
amp-front-0.1.0 design_docs/plugins.md