Permalink
Browse files

Create consistent 'name' var for all templates

Instead of each template having its own X_name variable, all templates
now just use name as a consistent interface to these Rebar templates.

For example, before we would run the rebar template runner like:
% rebar create template=ztmod module_name=blabla ....
% rebar create template=project project_name=ldfjdsl ...

Now we just do the following:
% rebar create template=X name=bla ...

Enjoy!
  • Loading branch information...
1 parent dbec776 commit 7defeb2a921d2a92398d8b881024dc7e57e9aba0 @mbbx6spp committed Feb 9, 2011
Showing with 58 additions and 58 deletions.
  1. +1 −1 ctsuite.erl
  2. +2 −2 ctsuite.template
  3. +3 −3 escript.template
  4. +5 −5 eunit.erl
  5. +2 −2 eunit.template
  6. +2 −2 finapp.app.src
  7. +4 −4 finapp.template
  8. +2 −2 finapp_app.erl
  9. +2 −2 nitropage.erl
  10. +2 −2 nitropage.template
  11. +2 −2 project.template
  12. +1 −1 project_README
  13. +1 −1 rebar_compiler.erl
  14. +3 −3 rebar_compiler.template
  15. +6 −6 rebar_compiler_SUITE.erl
  16. +1 −1 ztmod.erl
  17. +19 −19 ztmod.template
View
@@ -5,7 +5,7 @@
%%% @doc {{description}}
%%% @end
--module({{suite_name}}_SUITE).
+-module({{name}}_SUITE).
%% Note: This directive should only be used in test suites.
-compile(export_all).
-include_lib("common_test/include/ct.hrl").
View
@@ -1,8 +1,8 @@
{variables, [
- {suite_name, "suitename"},
+ {name, "suitename"},
{copyright_year, "2011"},
{author_name, "Susan Potter"},
{author_email,"me@susanpotter.net"}
]}.
{dir, "test"}.
-{template, "ctsuite.erl", "test/{{suite_name}}_SUITE.erl"}.
+{template, "ctsuite.erl", "test/{{name}}_SUITE.erl"}.
View
@@ -1,9 +1,9 @@
{variables, [
- {script_name, "escriptname"},
+ {name, "escriptname"},
{copyright_year, "2011"},
{author_name, "Susan Potter"},
{author_email,"me@susanpotter.net"}
]}.
{dir, "bin"}.
-{template, "escript", "bin/{{script_name}}"}.
-{chmod, 8#00770, "bin/{{script_name}}"}.
+{template, "escript", "bin/{{name}}"}.
+{chmod, 8#00770, "bin/{{name}}"}.
View
@@ -1,23 +1,23 @@
%%%' HEADER
%% @author {{author_name}} <{{author_name}}>
%% @copyright {{copyright_year}} {{author_name}}
-%% @doc EUnit test suite module {{module_name}}.
+%% @doc EUnit test suite module {{name}}.
%% @end
--module({{module_name}}_tests).
+-module({{name}}_tests).
-author('{{author_name}} <{{author_email}}>').
-define(NOTEST, true).
-define(NOASSERT, true).
-include_lib("eunit/include/eunit.hrl").
--define(MODNAME, {{module_name}}).
+-define(MODNAME, {{name}}).
%%%.
%%%' TEST GENERATOR
-%% @spec {{module_name}}_test_() -> List
+%% @spec {{name}}_test_() -> List
%% where
%% List = [term()]
-{{module_name}}_test_() ->
+{{name}}_test_() ->
%% add your asserts in the returned list, e.g.:
%% [
%% ?assert(?MODNAME:double(2) =:= 4),
View
@@ -1,8 +1,8 @@
{variables, [
- {module_name, "mymodule"},
+ {name, "mymodule"},
{copyright_year, "2011"},
{author_name, "Susan Potter"},
{author_email,"me@susanpotter.net"}
]}.
{dir, "tests"}.
-{template, "eunit.erl", "tests/{{module_name}}_tests.erl"}.
+{template, "eunit.erl", "tests/{{name}}_tests.erl"}.
View
@@ -1,5 +1,5 @@
%%-*- mode: erlang -*-
-{application, {{app_name}},
+{application, {{name}},
[
{description, "{{description}}"},
{vsn, "0.1.0"},
@@ -8,7 +8,7 @@
kernel,
stdlib
]},
- {mod, { {{app_name}}_app, []}},
+ {mod, { {{name}}_app, []}},
{env, []}
]}.
%% vim: set filetype=erlang tabstop=2
View
@@ -1,11 +1,11 @@
{variables, [
- {app_name, "appname"},
+ {name, "appname"},
{app_dir, "."},
{copyright_year, "2011"},
{author_name, "Susan Potter"},
{author_email,"me@susanpotter.net"}
]}.
{dir, "{{app_dir}}/src"}.
-{template, "finapp.app.src", "{{app_dir}}/src/{{app_name}}.app.src"}.
-{template, "finapp_app.erl", "{{app_dir}}/src/{{app_name}}_app.erl"}.
-{template, "finapp_sup.erl", "{{app_dir}}/src/{{app_name}}_sup.erl"}.
+{template, "finapp.app.src", "{{app_dir}}/src/{{name}}.app.src"}.
+{template, "finapp_app.erl", "{{app_dir}}/src/{{name}}_app.erl"}.
+{template, "finapp_sup.erl", "{{app_dir}}/src/{{name}}_sup.erl"}.
View
@@ -5,14 +5,14 @@
%%% @doc {{description}}
%%% @end
--module({{app_name}}_app).
+-module({{name}}_app).
-behaviour(application).
-export([start/2, stop/1]).
%%%.
%%%' CALLBACKS
start(_StartType, _StartArgs) ->
- {{app_name}}_sup:start_link().
+ {{name}}_sup:start_link().
stop(_State) ->
ok.
View
@@ -3,14 +3,14 @@
%%% @copyright {{copyright_year}} {{author_name}}
%%% @doc Nitrogen page handler for {{description}}
%%% @end
--module({{app_name}}_{{page_name}}_page).
+-module({{app_name}}_{{name}}_page).
-author('{{author_name}} <{{author_email}}>').
-include_lib("nitrogen_core/include/wf.hrl").
-compile(export_all).
%%%.
%%%' NITROGEN CALLBACKS
-main() -> #template { file="./templates/{{page_name}}.html" }.
+main() -> #template { file="./templates/{{name}}.html" }.
%%%.
%%%' TEMPLATE CALLBACKS
View
@@ -1,9 +1,9 @@
{variables, [
- {page_name, "pagename"},
+ {name, "pagename"},
{app_name, "app_name"},
{copyright_year, "2011"},
{author_name, "Susan Potter"},
{author_email,"me@susanpotter.net"}
]}.
{dir, "test"}.
-{template, "nitropage.erl", "src/{{app_name}}_{{page_name}}_page.erl"}.
+{template, "nitropage.erl", "src/{{app_name}}_{{name}}_page.erl"}.
View
@@ -1,6 +1,6 @@
{variables, [
- {project_name, "myproject"},
- {copyright_year, "2010"},
+ {name, "myproject"},
+ {copyright_year, "2011"},
{author_name, "Susan Potter"},
{author_email,"me@susanpotter.net"},
{description, "Fill in description of project here."}
View
@@ -1,4 +1,4 @@
-h1. {{project_name}}
+h1. {{name}}
{{description}}
View
@@ -4,7 +4,7 @@
%%% @doc rebar compiler to {{description}}
%%% @end
%%%----------------------------------------------------------------------
--module({{compiler_name}}).
+-module({{name}}).
-author('{{author_name}} <{{author_email}}>').
-export([compile/2]).
View
@@ -1,10 +1,10 @@
{variables, [
- {compiler_name, "compilername"},
+ {name, "compiler_name"},
{copyright_year, "2011"},
{author_name, "Susan Potter"},
{author_email,"me@susanpotter.net"}
]}.
{dir, "src"}.
-{template, "rebar_compiler.erl", "src/{{compiler_name}}.erl"}.
+{template, "rebar_compiler.erl", "src/{{name}}.erl"}.
{dir, "test"}.
-{template, "rebar_compiler_SUITE.erl", "test/{{compiler_name}}_SUITE.erl"}.
+{template, "rebar_compiler_SUITE.erl", "test/{{name}}_SUITE.erl"}.
View
@@ -1,9 +1,9 @@
%%% @author {{author_name}} <{{author_email}}>
%%% @copyright {{copyright_year}} {{author_name}}
-%%% @doc Test suite for {{compiler_name}} module which {{description}}
+%%% @doc Test suite for {{name}} module which {{description}}
%%% @end
--module({{compiler_name}}_SUITE).
+-module({{name}}_SUITE).
%% Note: This directive should only be used in test suites.
-compile(export_all).
-include_lib("common_test/include/ct.hrl").
@@ -121,11 +121,11 @@ test_compile_2_ok() ->
%% Reason = term(),
%% Comment = term()
%% @doc runs the test case function. Verifies the cases where
-%% {{compiler_name}}_compiler:compile/2 should return ok.
+%% {{name}}_compiler:compile/2 should return ok.
test_compile_2_ok(Config) ->
CompilerConfig = proplists:get_value(compiler_config, Config),
CompilerAppfile = proplists:get_value(compiler_appfile, Config),
- ok = {{compiler_name}}:compile(CompilerConfig, CompilerAppfile),
+ ok = {{name}}:compile(CompilerConfig, CompilerAppfile),
ok.
%% @spec TestCase() -> Info
@@ -144,10 +144,10 @@ test_compile_2_skipped() ->
%% Reason = term(),
%% Comment = term()
%% @doc runs the test case function. Verifies the cases where
-%% {{compiler_name}}_compiler:compile/2 should return ok.
+%% {{name}}_compiler:compile/2 should return ok.
test_compile_2_skipped(Config) ->
CompilerConfig = proplists:get_value(compiler_config, Config),
CompilerAppfile = proplists:get_value(compiler_appfile, Config),
- skipped = {{compiler_name}}:compile(CompilerConfig, CompilerAppfile),
+ skipped = {{name}}:compile(CompilerConfig, CompilerAppfile),
ok.
View
@@ -5,7 +5,7 @@
%%% {{description}}
%%% @end
--module(mod_{{module_name}}).
+-module(mod_{{name}}).
-author('{{author_name}} <{{author_email}}>').
-behaviour(gen_server).
View
@@ -1,27 +1,27 @@
{variables, [
- {module_name, "mymodule"},
+ {name, "mymodule"},
{module_title, "Zotonic Module Title"},
{module_priority, "500"},
{copyright_year, "2011"},
{author_name, "Susan Potter"},
{author_email,"me@susanpotter.net"},
{description, "<fill in description of Zotonic module here>."}
]}.
-{dir, ["mod_{{module_name}}"]}.
-{dir, ["mod_{{module_name}}", "actions"]}.
-{dir, ["mod_{{module_name}}", "dispatch"]}.
-{dir, ["mod_{{module_name}}", "lib"]}.
-{dir, ["mod_{{module_name}}", "lib", "css"]}.
-{dir, ["mod_{{module_name}}", "lib", "images"]}.
-{dir, ["mod_{{module_name}}", "lib", "js"]}.
-{dir, ["mod_{{module_name}}", "lib", "apps"]}.
-{dir, ["mod_{{module_name}}", "lib", "modules"]}.
-{dir, ["mod_{{module_name}}", "lib", "misc"]}.
-{dir, ["mod_{{module_name}}", "resources"]}.
-{dir, ["mod_{{module_name}}", "models"]}.
-{dir, ["mod_{{module_name}}", "scomps"]}.
-{dir, ["mod_{{module_name}}", "services"]}.
-{dir, ["mod_{{module_name}}", "templates"]}.
-{dir, ["mod_{{module_name}}", "filters"]}.
-{dir, ["mod_{{module_name}}", "validators"]}.
-{template, "ztmod.erl", "mod_{{module_name}}/mod_{{module_name}}.erl"}.
+{dir, ["mod_{{name}}"]}.
+{dir, ["mod_{{name}}", "actions"]}.
+{dir, ["mod_{{name}}", "dispatch"]}.
+{dir, ["mod_{{name}}", "lib"]}.
+{dir, ["mod_{{name}}", "lib", "css"]}.
+{dir, ["mod_{{name}}", "lib", "images"]}.
+{dir, ["mod_{{name}}", "lib", "js"]}.
+{dir, ["mod_{{name}}", "lib", "apps"]}.
+{dir, ["mod_{{name}}", "lib", "modules"]}.
+{dir, ["mod_{{name}}", "lib", "misc"]}.
+{dir, ["mod_{{name}}", "resources"]}.
+{dir, ["mod_{{name}}", "models"]}.
+{dir, ["mod_{{name}}", "scomps"]}.
+{dir, ["mod_{{name}}", "services"]}.
+{dir, ["mod_{{name}}", "templates"]}.
+{dir, ["mod_{{name}}", "filters"]}.
+{dir, ["mod_{{name}}", "validators"]}.
+{template, "ztmod.erl", "mod_{{name}}/mod_{{name}}.erl"}.

0 comments on commit 7defeb2

Please sign in to comment.