From 2d9af6cf485466d1b4e81707a8bb3ad8ebcd238b Mon Sep 17 00:00:00 2001 From: Dave Smith Date: Thu, 7 Jan 2010 22:18:55 -0700 Subject: Sketching out templating system --- priv/templates/simpleapp.app | 15 +++++++++++++++ priv/templates/simpleapp.template | 3 +++ priv/templates/simpleapp_app.erl | 16 ++++++++++++++++ priv/templates/simpleapp_sup.erl | 28 ++++++++++++++++++++++++++++ 4 files changed, 62 insertions(+) create mode 100644 priv/templates/simpleapp.app create mode 100644 priv/templates/simpleapp.template create mode 100644 priv/templates/simpleapp_app.erl create mode 100644 priv/templates/simpleapp_sup.erl (limited to 'priv') diff --git a/priv/templates/simpleapp.app b/priv/templates/simpleapp.app new file mode 100644 index 0000000..7638f51 --- /dev/null +++ b/priv/templates/simpleapp.app @@ -0,0 +1,15 @@ +{application, {{appid}}, + [ + {description, ""}, + {vsn, "1"}, + {modules, [ + {{appid}}_app, + {{appid}}_sup + ]}, + {registered, []}, + {applications, [ + kernel, + stdlib + ]}, + {env, []} + ]}. diff --git a/priv/templates/simpleapp.template b/priv/templates/simpleapp.template new file mode 100644 index 0000000..114e3bc --- /dev/null +++ b/priv/templates/simpleapp.template @@ -0,0 +1,3 @@ +{file, "simpleapp.app", "ebin/{{appid}}.app"}. +{file, "simpleapp_app.erl", "src/{{appid}}_app.erl"}. +{file, "simpleapp_sup.erl", "src/{{appid}}_sup.erl"}. \ No newline at end of file diff --git a/priv/templates/simpleapp_app.erl b/priv/templates/simpleapp_app.erl new file mode 100644 index 0000000..1af863b --- /dev/null +++ b/priv/templates/simpleapp_app.erl @@ -0,0 +1,16 @@ +-module({{appid}}_app). + +-behaviour(application). + +%% Application callbacks +-export([start/2, stop/1]). + +%% =================================================================== +%% Application callbacks +%% =================================================================== + +start(_StartType, _StartArgs) -> + {{appid}}_sup:start_link(). + +stop(_State) -> + ok. diff --git a/priv/templates/simpleapp_sup.erl b/priv/templates/simpleapp_sup.erl new file mode 100644 index 0000000..1dc178d --- /dev/null +++ b/priv/templates/simpleapp_sup.erl @@ -0,0 +1,28 @@ + +-module({{appid}}_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}, []}. + -- cgit v1.1