mirror of
https://github.com/correl/rebar.git
synced 2024-11-23 11:09:55 +00:00
Added 3 new templates:
- simplefsm - Basic shell of a gen_fsm module - simplesrv - Basic shell of a gen_server module - simplemod - Basic shell of a module along with an associated test module.
This commit is contained in:
parent
2734f2bcc2
commit
6c359a08cd
7 changed files with 124 additions and 0 deletions
55
priv/templates/simplefsm.erl
Normal file
55
priv/templates/simplefsm.erl
Normal file
|
@ -0,0 +1,55 @@
|
|||
-module({{fsmid}}).
|
||||
-behaviour(gen_fsm).
|
||||
-define(SERVER, ?MODULE).
|
||||
|
||||
%% ------------------------------------------------------------------
|
||||
%% API Function Exports
|
||||
%% ------------------------------------------------------------------
|
||||
|
||||
-export([start_link/0]).
|
||||
|
||||
%% ------------------------------------------------------------------
|
||||
%% gen_fsm Function Exports
|
||||
%% ------------------------------------------------------------------
|
||||
|
||||
-export([init/1, state_name/2, state_name/3, handle_event/3, handle_sync_event/4, handle_info/3, terminate/3, code_change/4]).
|
||||
|
||||
%% ------------------------------------------------------------------
|
||||
%% API Function Definitions
|
||||
%% ------------------------------------------------------------------
|
||||
|
||||
start_link() ->
|
||||
gen_fsm:start_link({local, ?SERVER}, ?MODULE, [], []).
|
||||
|
||||
%% ------------------------------------------------------------------
|
||||
%% gen_fsm Function Definitions
|
||||
%% ------------------------------------------------------------------
|
||||
|
||||
init(_Args) ->
|
||||
{ok, initial_state_name, initial_state}.
|
||||
|
||||
state_name(_Event, State) ->
|
||||
{next_state, state_name, State}.
|
||||
|
||||
state_name(_Event, _From, State) ->
|
||||
{reply, ok, state_name, State}.
|
||||
|
||||
handle_event(_Event, StateName, State) ->
|
||||
{next_state, StateName, State}.
|
||||
|
||||
handle_sync_event(_Event, _From, StateName, State) ->
|
||||
{reply, ok, StateName, State}.
|
||||
|
||||
handle_info(_Info, StateName, State) ->
|
||||
{next_state, StateName, State}.
|
||||
|
||||
terminate(_Reason, _StateName, _State) ->
|
||||
ok.
|
||||
|
||||
code_change(_OldVsn, StateName, State, _Extra) ->
|
||||
{ok, StateName, State}.
|
||||
|
||||
%% ------------------------------------------------------------------
|
||||
%% Internal Function Definitions
|
||||
%% ------------------------------------------------------------------
|
||||
|
2
priv/templates/simplefsm.template
Normal file
2
priv/templates/simplefsm.template
Normal file
|
@ -0,0 +1,2 @@
|
|||
{variables, [{fsmid, "myfsm"}]}.
|
||||
{file, "simplefsm.erl", "src/{{fsmid}}.erl"}.
|
10
priv/templates/simplemod.erl
Normal file
10
priv/templates/simplemod.erl
Normal file
|
@ -0,0 +1,10 @@
|
|||
-module({{modid}}).
|
||||
|
||||
-export([my_func/0]).
|
||||
|
||||
-ifdef(TEST).
|
||||
-compile(export_all).
|
||||
-endif.
|
||||
|
||||
my_func() ->
|
||||
ok.
|
3
priv/templates/simplemod.template
Normal file
3
priv/templates/simplemod.template
Normal file
|
@ -0,0 +1,3 @@
|
|||
{variables, [{modid, "mymod"}]}.
|
||||
{file, "simplemod.erl", "src/{{modid}}.erl"}.
|
||||
{file, "simplemod_tests.erl", "test/{{modid}}_tests.erl"}.
|
3
priv/templates/simplemod_tests.erl
Normal file
3
priv/templates/simplemod_tests.erl
Normal file
|
@ -0,0 +1,3 @@
|
|||
-module({{modid}}_tests).
|
||||
-include_lib("eunit/include/eunit.hrl").
|
||||
|
49
priv/templates/simplesrv.erl
Normal file
49
priv/templates/simplesrv.erl
Normal file
|
@ -0,0 +1,49 @@
|
|||
-module({{srvid}}).
|
||||
-behaviour(gen_server).
|
||||
-define(SERVER, ?MODULE).
|
||||
|
||||
%% ------------------------------------------------------------------
|
||||
%% API Function Exports
|
||||
%% ------------------------------------------------------------------
|
||||
|
||||
-export([start_link/0]).
|
||||
|
||||
%% ------------------------------------------------------------------
|
||||
%% gen_server Function Exports
|
||||
%% ------------------------------------------------------------------
|
||||
|
||||
-export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]).
|
||||
|
||||
%% ------------------------------------------------------------------
|
||||
%% API Function Definitions
|
||||
%% ------------------------------------------------------------------
|
||||
|
||||
start_link() ->
|
||||
gen_server:start_link({local, ?SERVER}, ?MODULE, [], []).
|
||||
|
||||
%% ------------------------------------------------------------------
|
||||
%% gen_server Function Definitions
|
||||
%% ------------------------------------------------------------------
|
||||
|
||||
init(Args) ->
|
||||
{ok, Args}.
|
||||
|
||||
handle_call(_Request, _From, State) ->
|
||||
{noreply, ok, State}.
|
||||
|
||||
handle_cast(_Msg, State) ->
|
||||
{noreply, State}.
|
||||
|
||||
handle_info(_Info, State) ->
|
||||
{noreply, State}.
|
||||
|
||||
terminate(_Reason, _State) ->
|
||||
ok.
|
||||
|
||||
code_change(_OldVsn, State, _Extra) ->
|
||||
{ok, State}.
|
||||
|
||||
%% ------------------------------------------------------------------
|
||||
%% Internal Function Definitions
|
||||
%% ------------------------------------------------------------------
|
||||
|
2
priv/templates/simplesrv.template
Normal file
2
priv/templates/simplesrv.template
Normal file
|
@ -0,0 +1,2 @@
|
|||
{variables, [{srvid, "myserver"}]}.
|
||||
{file, "simplesrv.erl", "src/{{srvid}}.erl"}.
|
Loading…
Reference in a new issue