diff options
author | Dave Smith <dizzyd@dizzyd.com> | 2010-01-07 22:18:55 -0700 |
---|---|---|
committer | Dave Smith <dizzyd@dizzyd.com> | 2010-01-07 22:18:55 -0700 |
commit | 2d9af6cf485466d1b4e81707a8bb3ad8ebcd238b (patch) | |
tree | f3fd554e0157cfdfd8d4536a29ac947e37021cf6 | |
parent | 3ed1b99438b3a0990f1f36d8aad69d7b82ccf663 (diff) |
Sketching out templating system
-rw-r--r-- | ebin/rebar.app | 7 | ||||
-rw-r--r-- | priv/templates/simpleapp.app | 15 | ||||
-rw-r--r-- | priv/templates/simpleapp.template | 3 | ||||
-rw-r--r-- | priv/templates/simpleapp_app.erl | 16 | ||||
-rw-r--r-- | priv/templates/simpleapp_sup.erl | 28 | ||||
-rw-r--r-- | src/rebar_templater.erl | 51 |
6 files changed, 118 insertions, 2 deletions
diff --git a/ebin/rebar.app b/ebin/rebar.app index 02a2094..d9e590c 100644 --- a/ebin/rebar.app +++ b/ebin/rebar.app @@ -23,8 +23,10 @@ rebar_rel_utils, rebar_reltool, rebar_subdirs, + rebar_templater, rebar_utils, - getopt ]}, + getopt, + mustache ]}, {registered, []}, {applications, [kernel, stdlib, @@ -39,7 +41,8 @@ %% any_dir processing modules {any_dir_modules, [ rebar_subdirs, - rebar_deps + rebar_deps, + rebar_templater ]}, %% Dir specific processing modules 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}, []}. + diff --git a/src/rebar_templater.erl b/src/rebar_templater.erl new file mode 100644 index 0000000..3c7c05f --- /dev/null +++ b/src/rebar_templater.erl @@ -0,0 +1,51 @@ +%% -*- tab-width: 4;erlang-indent-level: 4;indent-tabs-mode: nil -*- +%% ex: ts=4 sw=4 et +%% ------------------------------------------------------------------- +%% +%% rebar: Erlang Build Tools +%% +%% Copyright (c) 2009 Dave Smith (dizzyd@dizzyd.com) +%% +%% Permission is hereby granted, free of charge, to any person obtaining a copy +%% of this software and associated documentation files (the "Software"), to deal +%% in the Software without restriction, including without limitation the rights +%% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +%% copies of the Software, and to permit persons to whom the Software is +%% furnished to do so, subject to the following conditions: +%% +%% The above copyright notice and this permission notice shall be included in +%% all copies or substantial portions of the Software. +%% +%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +%% THE SOFTWARE. +%% ------------------------------------------------------------------- +-module(rebar_templater). + +-export([create/2]). + +-include("rebar.hrl"). + +%% =================================================================== +%% Public API +%% =================================================================== + +create(_Config, _) -> + ok. + + + +%% =================================================================== +%% Internal functions +%% =================================================================== + +% execute_template([]) -> +% ok; +% execute_template([{file, Input, Output} | Rest]) -> +% ok; +% execute_template([{dir, Name} | Rest]) -> +% ok. |