Permalink
Browse files

Fixed typos, added example of how to run a app.

  • Loading branch information...
1 parent 83e7019 commit d4cc969c2679f2be57ca323a3de82406317fd9c0 @Licenser committed Mar 17, 2013
View
@@ -5,14 +5,14 @@ This library intends to provide a simple way to manage plugins for an Erlang app
usage
-----
-Simply start the application, there is only one configuration variable at the moment named `plugin_dir` which as the name suggests specifies where the plugins are discovered. It defaults to `plugsin`.
+Simply start the application, there is only one configuration variable at the moment named `plugin_dir` which as the name suggests specifies where the plugins are discovered. It defaults to `"plugins"`.
apply/2
-------
This function can be used to call all the functions that were registered to a certain callback, with the args given as seconds argument.
```erlang
-eplugin:apply(my_fancy_callback, [1, 2, 3]).
+eplugin:apply(my_fancy_callÂback, [1, 2, 3]).
```
call/1+
@@ -48,7 +48,8 @@ eplugin:callbacks(my_fancy_callback).
config/1
--------
-Fetches the custom plugin Config. This can is not tied to anything but simply can be used to store whatever plugin config is required.
+Fetches the custom plugin Config. This is holding plugin internal information as well as some used by eplugin.
+
```erlang
eplugin:config(my_fancy_callback).
%% -> {ok, Config}
@@ -59,7 +60,7 @@ plugins/0
This function lists all installed plugins.
enable/1
---------
+--------˘
Enables a plugin.
disable/1
@@ -77,7 +78,7 @@ Registers a callback.
Writing plugins
===============
-A plugin is a directory with a `plugin.conf` file and one or more .erl files so the a plugin directory could look like:
+A plugin is a directory with a `plugin.conf` file and one or more .erl files so the plugin directory could look like:
```
-plugins
-plug1
@@ -99,14 +100,14 @@ The plugin.conf is a simple file with the following syntax:
OptionPlist}.
```
-CallbackOptions has the following possbile values
+CallbackOptions has the following possible values
* priority - the priority for execution order, highest priority first, default is 0
OptionsPlist has the following reserved options:
* disabled - this plugin will not load.
-* dependencies - a list of dependencies.
-* provides - a list of dependencies the plug provides.
+* dependencies - a list of dependencies.¯
+* provides - a list of dependencies the plugin provides.
Callbacks
=========
@@ -115,10 +116,10 @@ notation
--------
callbacks are noted as `<callback name>(arguments)` so `eplugin:init(Config)` means the callback `eplugin:init` is called with 1 argument - `Config`.
-internal callbacks
+internal callbacks¯¯
------------------
eplugin provides the following callbacks itself:
* eplugin:enable(Config) - this is called before a module gets enabled.
* eplugin:disable(Config) - this gets called after a module gets disabled.
* eplugin:enable_plugin(Plugin) - this gets called whenever a plugin is enabled.
-* eplugin:disable_plugin(Plugin) - this gets called whenever a plugin is disabled.
+* eplugin:disable_plugin(Plugin) - this gets called whenever a plugin is disabled.
@@ -0,0 +1,12 @@
+{application, example_app,
+ [
+ {description, ""},
+ {vsn, "1"},
+ {registered, []},
+ {applications, [
+ kernel,
+ stdlib
+ ]},
+ {mod, { example_app_app, []}},
+ {env, []}
+ ]}.
@@ -0,0 +1,6 @@
+-module(example_app).
+
+-export([start/0]).
+
+start() ->
+ example_app_app:start([],[]).
@@ -0,0 +1,16 @@
+-module(example_app_app).
+
+-behaviour(application).
+
+%% Application callbacks
+-export([start/2, stop/1]).
+
+%% ===================================================================
+%% Application callbacks
+%% ===================================================================
+
+start(_StartType, _StartArgs) ->
+ example_app_sup:start_link().
+
+stop(_State) ->
+ ok.
@@ -0,0 +1,28 @@
+
+-module(example_app_sup).
+
+-behaviour(supervisor).
+
+%% API
+-export([start_link/0]).
+
+%% Supervisor callbacks
+-export([init/1]).
+
+%% Helper macro for declaring children of supervisor
+-define(CHILD(I, Type), {I, {I, start_link, []}, permanent, 5000, Type, [I]}).
+
+%% ===================================================================
+%% API functions
+%% ===================================================================
+
+start_link() ->
+ supervisor:start_link({local, ?MODULE}, ?MODULE, []).
+
+%% ===================================================================
+%% Supervisor callbacks
+%% ===================================================================
+
+init([]) ->
+ {ok, { {one_for_one, 5, 10}, []} }.
+
@@ -0,0 +1,5 @@
+{example_app,
+ [{example_app_app, []},
+ {example_app_sup, []},
+ {example_app, [{'eplugin:enable', start}]}],
+ []}.
View
@@ -196,7 +196,7 @@ load_modules(Name, Path, [{M, _RegisterFor} | Modules]) ->
end.
compile_modules(Name, _Paht, []) ->
- lager:info("[eplugin::~p] All modules compiled successfully.", [Name]),
+ lager:info("[eplugin::~p] All modules compiled successfuly.", [Name]),
ok;
compile_modules(Name, Path, [{M, _RegisterFor} | Modules]) ->
@@ -219,10 +219,10 @@ compile_module(Name, Path, Module) ->
lager:error("[eplugin::~p] Compiling failed. Errors: ~p Warnings: ~p.", [Name, Errors, Warnings]),
{error, {Errors, Warnings}};
{ok, ModuleName} ->
- lager:info("[eplugin::~p] Compiling successfull of ~p.", [Name, ModuleName]),
+ lager:info("[eplugin::~p] Compiling successful of ~p.", [Name, ModuleName]),
{ok, ModuleName};
{ok, ModuleName,Warnings} ->
- lager:info("[eplugin::~p] Compiling successfull of ~p with warnings: ~p.", [Name, ModuleName, Warnings]),
+ lager:info("[eplugin::~p] Compiling successful of ~p with warnings: ~p.", [Name, ModuleName, Warnings]),
{ok, ModuleName}
end.

0 comments on commit d4cc969

Please sign in to comment.