From 8723c2cadaa638db84a8b3c97ded2157cfe6c44e Mon Sep 17 00:00:00 2001 From: derwinlu Date: Wed, 17 Feb 2016 18:08:06 +0100 Subject: Add 'module' template Every .erl source file will need at least a -module and a single -export definition. With the 'module' template a file can be quickly created that already populates -module with the right value as well as an empty export field. --- plugins/bootstrap.mk | 5 +++++ test/plugin_bootstrap.mk | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/plugins/bootstrap.mk b/plugins/bootstrap.mk index 4aa1052..5ece8f9 100644 --- a/plugins/bootstrap.mk +++ b/plugins/bootstrap.mk @@ -172,6 +172,11 @@ code_change(_OldVsn, State, _Extra) -> {ok, State}. endef +define tpl_module +-module($(n)). +-export([]). +endef + define tpl_cowboy_http -module($(n)). -behaviour(cowboy_http_handler). diff --git a/test/plugin_bootstrap.mk b/test/plugin_bootstrap.mk index ebfa6e7..2b62b6f 100644 --- a/test/plugin_bootstrap.mk +++ b/test/plugin_bootstrap.mk @@ -190,6 +190,7 @@ bootstrap-templates: build clean $t $(MAKE) -C $(APP) --no-print-directory new t=cowboy_rest n=my_rest $t $(MAKE) -C $(APP) --no-print-directory new t=cowboy_ws n=my_ws $t $(MAKE) -C $(APP) --no-print-directory new t=ranch_protocol n=my_protocol + $t $(MAKE) -C $(APP) --no-print-directory new t=module n=my_module # Here we disable warnings because templates contain missing behaviors. $i "Build the application" @@ -200,11 +201,12 @@ bootstrap-templates: build clean $t test -f $(APP)/ebin/my_fsm.beam $t test -f $(APP)/ebin/my_server.beam $t test -f $(APP)/ebin/my_sup.beam + $t test -f $(APP)/ebin/my_module.beam $i "Check that all the modules can be loaded" $t $(ERL) -pa $(APP)/ebin/ -eval " \ ok = application:start($(APP)), \ - {ok, Mods = [my_fsm, my_http, my_loop, my_protocol, my_rest, my_server, my_sup, my_ws]} \ + {ok, Mods = [my_fsm, my_http, my_loop, my_module, my_protocol, my_rest, my_server, my_sup, my_ws]} \ = application:get_key($(APP), modules), \ [{module, M} = code:load_file(M) || M <- Mods], \ halt()" -- cgit v1.2.3