first commit
This commit is contained in:
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
globals
|
||||
**~
|
||||
60
_app.template
Normal file
60
_app.template
Normal file
@@ -0,0 +1,60 @@
|
||||
{description, "Custom app with ct test and c_src directory"}.
|
||||
|
||||
{variables, [
|
||||
{license, "apache-2.0", "default license"}
|
||||
]}.
|
||||
|
||||
{dir, "{{name}}"}.
|
||||
{dir, "{{name}}/src"}.
|
||||
{dir, "{{name}}/include"}.
|
||||
{dir, "{{name}}/test"}.
|
||||
{dir, "{{name}}/c_src"}.
|
||||
|
||||
{file, "_app/.gitignore", "{{name}}/.gitignore"}.
|
||||
{chmod, "{{name}}/.gitignore", 8#644}.
|
||||
|
||||
{template, "_app/README.md", "{{name}}/README.md"}.
|
||||
{chmod, "{{name}}/README.md", 8#644}.
|
||||
|
||||
{template, "_app/LICENSE-{{license}}", "{{name}}/LICENSE"}.
|
||||
{chmod, "{{name}}/LICENSE", 8#644}.
|
||||
|
||||
{template, "_app/rebar.config", "{{name}}/rebar.config"}.
|
||||
{chmod, "{{name}}/rebar.config", 8#644}.
|
||||
|
||||
{template, "_app/src/name.app.src", "{{name}}/src/{{name}}.app.src"}.
|
||||
{chmod, "{{name}}/src/{{name}}.app.src", 8#644}.
|
||||
|
||||
{template, "_app/src/name_app.erl", "{{name}}/src/{{name}}_app.erl"}.
|
||||
{chmod, "{{name}}/src/{{name}}_app.erl", 8#644}.
|
||||
|
||||
{template, "_app/src/name_sup.erl", "{{name}}/src/{{name}}_sup.erl"}.
|
||||
{chmod, "{{name}}/src/{{name}}_sup.erl", 8#644}.
|
||||
|
||||
{template, "_app/src/name_server.erl", "{{name}}/src/{{name}}_server.erl"}.
|
||||
{chmod, "{{name}}/src/{{name}}_server.erl", 8#644}.
|
||||
|
||||
{template, "_app/src/name_statem.erl", "{{name}}/src/{{name}}_statem.erl"}.
|
||||
{chmod, "{{name}}/src/{{name}}_statem.erl", 8#644}.
|
||||
|
||||
{template, "_app/include/name.hrl", "{{name}}/include/{{name}}.hrl"}.
|
||||
{chmod, "{{name}}/include/{{name}}.hrl", 8#644}.
|
||||
|
||||
{template, "_app/test/name_SUITE.erl", "{{name}}/test/{{name}}_SUITE.erl"}.
|
||||
{chmod, "{{name}}/test/{{name}}_SUITE.erl", 8#644}.
|
||||
|
||||
{template, "_app/c_src/Makefile", "{{name}}/c_src/Makefile"}.
|
||||
{chmod, "{{name}}/c_src/Makefile", 8#644}.
|
||||
|
||||
{template, "_app/c_src/name.c", "{{name}}/c_src/{{name}}.c"}.
|
||||
{chmod, "{{name}}/c_src/{{name}}.c", 8#644}.
|
||||
|
||||
{template, "_app/c_src/name.h", "{{name}}/c_src/{{name}}.h"}.
|
||||
{chmod, "{{name}}/c_src/{{name}}.h", 8#644}.
|
||||
|
||||
{template, "_app/c_src/name_test.c", "{{name}}/c_src/{{name}}_test.c"}.
|
||||
{chmod, "{{name}}/c_src/{{name}}_test.c", 8#644}.
|
||||
|
||||
{file, "_app/c_src/minunit.h", "{{name}}/c_src/minunit.h"}.
|
||||
{chmod, "{{name}}/c_src/minunit.h", 8#644}.
|
||||
|
||||
18
_app/.gitignore
vendored
Normal file
18
_app/.gitignore
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
.rebar3
|
||||
_*
|
||||
.eunit
|
||||
*.o
|
||||
*.beam
|
||||
*.plt
|
||||
*.swp
|
||||
*.swo
|
||||
.erlang.cookie
|
||||
ebin
|
||||
log
|
||||
erl_crash.dump
|
||||
.rebar
|
||||
logs
|
||||
_build
|
||||
.idea
|
||||
rebar3.crashdump
|
||||
**~
|
||||
146
_app/LICENSE-Artistic-Clarified
Normal file
146
_app/LICENSE-Artistic-Clarified
Normal file
@@ -0,0 +1,146 @@
|
||||
The Clarified Artistic License
|
||||
|
||||
Preamble
|
||||
|
||||
The intent of this document is to state the conditions under which a
|
||||
Package may be copied, such that the Copyright Holder maintains some
|
||||
semblance of artistic control over the development of the package,
|
||||
while giving the users of the package the right to use and distribute
|
||||
the Package in a more-or-less customary fashion, plus the right to
|
||||
make reasonable modifications.
|
||||
|
||||
Definitions:
|
||||
|
||||
"Package" refers to the collection of files distributed by the
|
||||
Copyright Holder, and derivatives of that collection of files
|
||||
created through textual modification.
|
||||
|
||||
"Standard Version" refers to such a Package if it has not been
|
||||
modified, or has been modified in accordance with the wishes of the
|
||||
Copyright Holder as specified below.
|
||||
|
||||
"Copyright Holder" is whoever is named in the copyright or copyrights
|
||||
for the package.
|
||||
|
||||
"You" is you, if you're thinking about copying or distributing this
|
||||
Package.
|
||||
|
||||
"Distribution fee" is a fee you charge for providing a copy of this
|
||||
Package to another party.
|
||||
|
||||
"Freely Available" means that no fee is charged for the right to use
|
||||
the item, though there may be fees involved in handling the item.
|
||||
It also means that recipients of the item may redistribute it under
|
||||
the same conditions they received it.
|
||||
|
||||
1. You may make and give away verbatim copies of the source form of
|
||||
the Standard Version of this Package without restriction, provided
|
||||
that you duplicate all of the original copyright notices and
|
||||
associated disclaimers.
|
||||
|
||||
2. You may apply bug fixes, portability fixes and other modifications
|
||||
derived from the Public Domain, or those made Freely Available, or
|
||||
from the Copyright Holder. A Package modified in such a way shall
|
||||
still be considered the Standard Version.
|
||||
|
||||
3. You may otherwise modify your copy of this Package in any way,
|
||||
provided that you insert a prominent notice in each changed file
|
||||
stating how and when you changed that file, and provided that you
|
||||
do at least ONE of the following:
|
||||
|
||||
a) place your modifications in the Public Domain or otherwise make
|
||||
them Freely Available, such as by posting said modifications to
|
||||
Usenet or an equivalent medium, or placing the modifications on
|
||||
a major network archive site allowing unrestricted access to
|
||||
them, or by allowing the Copyright Holder to include your
|
||||
modifications in the Standard Version of the Package.
|
||||
|
||||
b) use the modified Package only within your corporation or
|
||||
organization.
|
||||
|
||||
c) rename any non-standard executables so the names do not
|
||||
conflict with standard executables, which must also be
|
||||
provided, and provide a separate manual page for each
|
||||
non-standard executable that clearly documents how it differs
|
||||
from the Standard Version.
|
||||
|
||||
d) make other distribution arrangements with the Copyright Holder.
|
||||
|
||||
e) permit and encourge anyone who receives a copy of the modified
|
||||
Package permission to make your modifications Freely Available
|
||||
in some specific way.
|
||||
|
||||
|
||||
4. You may distribute the programs of this Package in object code or
|
||||
executable form, provided that you do at least ONE of the
|
||||
following:
|
||||
|
||||
a) distribute a Standard Version of the executables and library
|
||||
files, together with instructions (in the manual page or
|
||||
equivalent) on where to get the Standard Version.
|
||||
|
||||
b) accompany the distribution with the machine-readable source of
|
||||
the Package with your modifications.
|
||||
|
||||
c) give non-standard executables non-standard names, and clearly
|
||||
document the differences in manual pages (or equivalent),
|
||||
together with instructions on where to get the Standard
|
||||
Version.
|
||||
|
||||
d) make other distribution arrangements with the Copyright Holder.
|
||||
|
||||
e) offer the machine-readable source of the Package, with your
|
||||
modifications, by mail order.
|
||||
|
||||
5. You may charge a distribution fee for any distribution of this
|
||||
Package. If you offer support for this Package, you may charge any
|
||||
fee you choose for that support. You may not charge a license fee
|
||||
for the right to use this Package itself. You may distribute this
|
||||
Package in aggregate with other (possibly commercial and possibly
|
||||
nonfree) programs as part of a larger (possibly commercial and
|
||||
possibly nonfree) software distribution, and charge license fees
|
||||
for other parts of that software distribution, provided that you do
|
||||
not advertise this Package as a product of your own. If the
|
||||
Package includes an interpreter, You may embed this Package's
|
||||
interpreter within an executable of yours (by linking); this shall
|
||||
be construed as a mere form of aggregation, provided that the
|
||||
complete Standard Version of the interpreter is so embedded.
|
||||
|
||||
6. The scripts and library files supplied as input to or produced as
|
||||
output from the programs of this Package do not automatically fall
|
||||
under the copyright of this Package, but belong to whoever
|
||||
generated them, and may be sold commercially, and may be aggregated
|
||||
with this Package. If such scripts or library files are aggregated
|
||||
with this Package via the so-called "undump" or "unexec" methods of
|
||||
producing a binary executable image, then distribution of such an
|
||||
image shall neither be construed as a distribution of this Package
|
||||
nor shall it fall under the restrictions of Paragraphs 3 and 4,
|
||||
provided that you do not represent such an executable image as a
|
||||
Standard Version of this Package.
|
||||
|
||||
7. C subroutines (or comparably compiled subroutines in other
|
||||
languages) supplied by you and linked into this Package in order to
|
||||
emulate subroutines and variables of the language defined by this
|
||||
Package shall not be considered part of this Package, but are the
|
||||
equivalent of input as in Paragraph 6, provided these subroutines
|
||||
do not change the language in any way that would cause it to fail
|
||||
the regression tests for the language.
|
||||
|
||||
8. Aggregation of the Standard Version of the Package with a
|
||||
commercial distribution is always permitted provided that the use
|
||||
of this Package is embedded; that is, when no overt attempt is made
|
||||
to make this Package's interfaces visible to the end user of the
|
||||
commercial distribution. Such use shall not be construed as a
|
||||
distribution of this Package.
|
||||
|
||||
9. The name of the Copyright Holder may not be used to endorse or
|
||||
promote products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
10. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
|
||||
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE.
|
||||
|
||||
The End
|
||||
|
||||
13
_app/LICENSE-BSD0
Normal file
13
_app/LICENSE-BSD0
Normal file
@@ -0,0 +1,13 @@
|
||||
Copyright (C) {{copyright_year}} by {{author_name}} <{{author_email}}>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for
|
||||
any purpose with or without fee is hereby granted.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
|
||||
WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
|
||||
AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
PERFORMANCE OF THIS SOFTWARE.
|
||||
29
_app/LICENSE-BSD3
Normal file
29
_app/LICENSE-BSD3
Normal file
@@ -0,0 +1,29 @@
|
||||
Copyright (c) {{copyright_year}} {{author_name}} <{{author_email}}
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
|
||||
* Neither the name of the {{author_name}} nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL {{author_name}}
|
||||
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
34
_app/LICENSE-BSD4
Normal file
34
_app/LICENSE-BSD4
Normal file
@@ -0,0 +1,34 @@
|
||||
Copyright (c) {{copyright_year}}, {{author_name}} <{{author_email}}>
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
|
||||
3. All advertising materials mentioning features or use of this
|
||||
software must display the following acknowledgement: This product
|
||||
includes software developed by the {{author_name}}.
|
||||
|
||||
4. Neither the name of the {{author_name}} nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY {{author_name}} ''AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
6
_app/LICENSE-Beerware
Normal file
6
_app/LICENSE-Beerware
Normal file
@@ -0,0 +1,6 @@
|
||||
"THE BEER-WARE LICENSE" (Revision 42):
|
||||
|
||||
{{author_name}} <{{author_email}}> wrote this file. As long as you
|
||||
retain this notice you can do whatever you want with this stuff. If we
|
||||
meet some day, and you think this stuff is worth it, you can buy me a
|
||||
beer in return.
|
||||
15
_app/LICENSE-ISC
Normal file
15
_app/LICENSE-ISC
Normal file
@@ -0,0 +1,15 @@
|
||||
Copyright {{copyright_year}} {{author_name}} <{{author_email}}>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for
|
||||
any purpose with or without fee is hereby granted, provided that the
|
||||
above copyright notice and this permission notice appear in all
|
||||
copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
|
||||
WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
|
||||
AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
PERFORMANCE OF THIS SOFTWARE.
|
||||
14
_app/LICENSE-ISC-OpenBSD
Normal file
14
_app/LICENSE-ISC-OpenBSD
Normal file
@@ -0,0 +1,14 @@
|
||||
Copyright (c) {{copyright_year}} {{author_name}} <{{author_email}}>
|
||||
|
||||
Permission to use, copy, modify, and distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
|
||||
WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
|
||||
AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
PERFORMANCE OF THIS SOFTWARE.
|
||||
20
_app/LICENSE-MIT
Normal file
20
_app/LICENSE-MIT
Normal file
@@ -0,0 +1,20 @@
|
||||
Copyright (c) {{copyright_year}} {{author_name}} <{{author_email}}>
|
||||
|
||||
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.
|
||||
25
_app/LICENSE-Unlicense
Normal file
25
_app/LICENSE-Unlicense
Normal file
@@ -0,0 +1,25 @@
|
||||
This is free and unencumbered software released into the public
|
||||
domain.
|
||||
|
||||
Anyone is free to copy, modify, publish, use, compile, sell, or
|
||||
distribute this software, either in source code form or as a compiled
|
||||
binary, for any purpose, commercial or non-commercial, and by any
|
||||
means.
|
||||
|
||||
In jurisdictions that recognize copyright laws, the author or authors
|
||||
of this software dedicate any and all copyright interest in the
|
||||
software to the public domain. We make this dedication for the benefit
|
||||
of the public at large and to the detriment of our heirs and
|
||||
successors. We intend this dedication to be an overt act of
|
||||
relinquishment in perpetuity of all present and future rights to this
|
||||
software under copyright law.
|
||||
|
||||
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 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.
|
||||
|
||||
For more information, please refer to <http://unlicense.org/>
|
||||
13
_app/LICENSE-WTFPL
Normal file
13
_app/LICENSE-WTFPL
Normal file
@@ -0,0 +1,13 @@
|
||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||
Version 2, December 2004
|
||||
|
||||
Copyright (C) {{copyright_year}} {{author_name}} <{{author_email}}>
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim or modified
|
||||
copies of this license document, and changing it is allowed as long as
|
||||
the name is changed.
|
||||
|
||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE TERMS AND CONDITIONS
|
||||
FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. You just DO WHAT THE FUCK YOU WANT TO.
|
||||
191
_app/LICENSE-apache-2.0
Normal file
191
_app/LICENSE-apache-2.0
Normal file
@@ -0,0 +1,191 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
Copyright {{copyright_year}}, {{author_name}} <{{author_email}}>.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
21
_app/README.md
Normal file
21
_app/README.md
Normal file
@@ -0,0 +1,21 @@
|
||||
# {{name}}
|
||||
|
||||
{{name}} is an application...
|
||||
|
||||
## Usage
|
||||
|
||||
```sh
|
||||
rebar3 compile
|
||||
```
|
||||
|
||||
## Test
|
||||
|
||||
```sh
|
||||
rebar3 ct
|
||||
rebar3 eunit
|
||||
```
|
||||
|
||||
# About
|
||||
|
||||
Made with <3 by {{author_name}} with [Erlang](erlang.org/) and
|
||||
[rebar3](https://www.rebar3.org).
|
||||
20
_app/c_src/Makefile
Normal file
20
_app/c_src/Makefile
Normal file
@@ -0,0 +1,20 @@
|
||||
# GNU Makefile for {{name}} application
|
||||
all: {{name}}_test {{name}}
|
||||
|
||||
CC_OPTS_WARNINGS = -Wall -Wextra -Wconversion -Wdouble-promotion
|
||||
CC_OPTS_WARNINGS += -Wno-unused-parameter -Wno-unused-function -Wno-sign-conversion
|
||||
CC_OPTS_SANITIZE = -fsanitize=undefined -fsanitize-trap -fsanitize=address
|
||||
CC_OPTS_DEBUG = -g3
|
||||
CC_OPTS = $(CC_OPTS_DEBUG) $(CC_OPTS_WARNINGS) $(CC_OPTS_SANITIZE)
|
||||
CC = cc $CC_OPTS)
|
||||
|
||||
{{name}}:
|
||||
$(CC) $@.c -o $@
|
||||
|
||||
{{name}}_test:
|
||||
$(CC) $@.c -o $@
|
||||
./$@
|
||||
|
||||
clean:
|
||||
rm {{name}}
|
||||
rm {{name}}_test
|
||||
6
_app/c_src/minunit.h
Normal file
6
_app/c_src/minunit.h
Normal file
@@ -0,0 +1,6 @@
|
||||
/* file: minunit.h */
|
||||
/* http://www.jera.com/techinfo/jtns/jtn002.html */
|
||||
#define mu_assert(message, test) do { if (!(test)) return message; } while (0)
|
||||
#define mu_run_test(test) do { char *message = test(); tests_run++; \
|
||||
if (message) return message; } while (0)
|
||||
extern int tests_run;
|
||||
8
_app/c_src/name.c
Normal file
8
_app/c_src/name.c
Normal file
@@ -0,0 +1,8 @@
|
||||
/* file {{name}}.c */
|
||||
|
||||
#include "{{name}}.h"
|
||||
|
||||
int
|
||||
main(int argc, char *argv[]) {
|
||||
return 0;
|
||||
}
|
||||
1
_app/c_src/name.h
Normal file
1
_app/c_src/name.h
Normal file
@@ -0,0 +1 @@
|
||||
/* file {{name}}.h */
|
||||
43
_app/c_src/name_test.c
Normal file
43
_app/c_src/name_test.c
Normal file
@@ -0,0 +1,43 @@
|
||||
/* file {{name}}_test.c */
|
||||
/* http://www.jera.com/techinfo/jtns/jtn002.html */
|
||||
|
||||
#include <stdio.h>
|
||||
#include "minunit.h"
|
||||
|
||||
int tests_run = 0;
|
||||
|
||||
int foo = 7;
|
||||
int bar = 4;
|
||||
|
||||
static char *
|
||||
test_foo() {
|
||||
mu_assert("error, foo != 7", foo == 7);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static char *
|
||||
test_bar() {
|
||||
mu_assert("error, bar != 5", bar != 5);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static char *
|
||||
all_tests() {
|
||||
mu_run_test(test_foo);
|
||||
mu_run_test(test_bar);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv) {
|
||||
char *result = all_tests();
|
||||
if (result != 0) {
|
||||
printf("%s\n", result);
|
||||
}
|
||||
else {
|
||||
printf("ALL TESTS PASSED\n");
|
||||
}
|
||||
printf("Tests run: %d\n", tests_run);
|
||||
|
||||
return result != 0;
|
||||
}
|
||||
4
_app/include/name.hrl
Normal file
4
_app/include/name.hrl
Normal file
@@ -0,0 +1,4 @@
|
||||
%%%-------------------------------------------------------------------
|
||||
%%% @author {{author_name}} <{{author_email}}>
|
||||
%%% @copyright {{copyright_year}} (c) {{author_name}} <{{author_email}}>
|
||||
%%%-------------------------------------------------------------------
|
||||
7
_app/rebar.config
Normal file
7
_app/rebar.config
Normal file
@@ -0,0 +1,7 @@
|
||||
{erl_opts, [debug_info]}.
|
||||
{deps, []}.
|
||||
|
||||
{shell, [
|
||||
% {config, "config/sys.config"},
|
||||
{apps, [{{name}}]}
|
||||
]}.
|
||||
14
_app/src/name.app.src
Normal file
14
_app/src/name.app.src
Normal file
@@ -0,0 +1,14 @@
|
||||
{application, {{name}},
|
||||
[{description, "{{name}} application"},
|
||||
{vsn, "0.1.0"},
|
||||
{registered, [{{name}}_sup]},
|
||||
{mod, {{{name}}_app, []}},
|
||||
{applications,
|
||||
[kernel,
|
||||
stdlib
|
||||
]},
|
||||
{env,[]},
|
||||
{modules, []},
|
||||
{licenses, ["Apache 2.0"]},
|
||||
{links, []}
|
||||
]}.
|
||||
31
_app/src/name_app.erl
Normal file
31
_app/src/name_app.erl
Normal file
@@ -0,0 +1,31 @@
|
||||
%%%-------------------------------------------------------------------
|
||||
%%% @author {{author_name}} <{{author_email}}>
|
||||
%%% @copyright {{copyright_year}} (c) {{author_name}}
|
||||
%%%
|
||||
%%% @doc {{name}} main application
|
||||
%%% @end
|
||||
%%%-------------------------------------------------------------------
|
||||
-module({{name}}_app).
|
||||
-behaviour(application).
|
||||
-export([start/2, stop/1]).
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
%% @doc start/2
|
||||
%% @end
|
||||
%%--------------------------------------------------------------------
|
||||
-spec start(StartType, StartArgs) -> Return when
|
||||
StartType :: application:start_type(),
|
||||
StartArgs :: term(),
|
||||
Return :: pid().
|
||||
start(_StartType, _StartArgs) ->
|
||||
{{name}}_sup:start_link().
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
%% @doc stop/1
|
||||
%% @end
|
||||
%%--------------------------------------------------------------------
|
||||
-spec stop(State) -> Return when
|
||||
State :: term(),
|
||||
Return :: ok.
|
||||
stop(_State) ->
|
||||
ok.
|
||||
163
_app/src/name_server.erl
Normal file
163
_app/src/name_server.erl
Normal file
@@ -0,0 +1,163 @@
|
||||
%%%-------------------------------------------------------------------
|
||||
%%% @author {{author_name}} <{{author_email}}>
|
||||
%%% @copyright {{copyright_year}} (c) {{author_name}}
|
||||
%%%
|
||||
%%% @doc gen_server template for {{name}} application
|
||||
%%% @end
|
||||
%%%-------------------------------------------------------------------
|
||||
-module({{name}}_server).
|
||||
-behaviour(gen_server).
|
||||
-export([start/0, start/1, start/2, start/3]).
|
||||
-export([start_link/0, start_link/1, start_link/2, start_link/3]).
|
||||
-export([init/1, terminate/2]).
|
||||
-export([handle_call/3, handle_cast/2, handle_info/2]).
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
%% @doc start/0
|
||||
%% @end
|
||||
%%--------------------------------------------------------------------
|
||||
-spec start() -> Return when
|
||||
Return :: {ok, pid()} | ignore | {error, Error},
|
||||
Error :: {already_started, pid()} | term().
|
||||
start() ->
|
||||
start([]).
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
%% @doc start/1
|
||||
%% @end
|
||||
%%--------------------------------------------------------------------
|
||||
-spec start(Args) -> Return when
|
||||
Args :: term(),
|
||||
Return :: {ok, pid()} | ignore | {error, Error},
|
||||
Error :: {already_started, pid()} | term().
|
||||
start(Args) ->
|
||||
start(Args, []).
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
%% @doc start/2
|
||||
%% @end
|
||||
%%--------------------------------------------------------------------
|
||||
-spec start(Args, Opts) -> Return when
|
||||
Args :: term(),
|
||||
Opts :: [term()],
|
||||
Return :: {ok, pid()} | ignore | {error, Error},
|
||||
Error :: {already_started, pid()} | term().
|
||||
start(Args, Opts) ->
|
||||
gen_server:start(?MODULE, Args, Opts).
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
%% @doc start/3
|
||||
%% @end
|
||||
%%--------------------------------------------------------------------
|
||||
-spec start(Name, Args, Opts) -> Return when
|
||||
Name :: atom(),
|
||||
Args :: term(),
|
||||
Opts :: [term()],
|
||||
Return :: {ok, pid()} | ignore | {error, Error},
|
||||
Error :: {already_started, pid()} | term().
|
||||
start(Name, Args, Opts) ->
|
||||
gen_server:start({local, ?MODULE}, ?MODULE, Args, Opts).
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
%% @doc start_link/0
|
||||
%% @end
|
||||
%%--------------------------------------------------------------------
|
||||
-spec start_link() -> Return when
|
||||
Return :: {ok, pid()} | ignore | {error, Error},
|
||||
Error :: {already_started, pid()} | term().
|
||||
start_link() ->
|
||||
start_link([]).
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
%% @doc start_link/1
|
||||
%% @end
|
||||
%%--------------------------------------------------------------------
|
||||
-spec start_link(Args) -> Return when
|
||||
Args :: term(),
|
||||
Return :: {ok, pid()} | ignore | {error, Error},
|
||||
Error :: {already_started, pid()} | term().
|
||||
start_link(Args) ->
|
||||
start_link(Args, []).
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
%% @doc start_link/2
|
||||
%% @end
|
||||
%%--------------------------------------------------------------------
|
||||
-spec start_link(Args, Opts) -> Return when
|
||||
Args :: term(),
|
||||
Opts :: [term()],
|
||||
Return :: {ok, pid()} | ignore | {error, Error},
|
||||
Error :: {already_started, pid()} | term().
|
||||
start_link(Args, Opts) ->
|
||||
gen_server:start_link(?MODULE, Args, Opts).
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
%% @doc start_link/3
|
||||
%% @end
|
||||
%%--------------------------------------------------------------------
|
||||
-spec start_link(Name, Args, Opts) -> Return when
|
||||
Name :: atom(),
|
||||
Args :: term(),
|
||||
Opts :: [term()],
|
||||
Return :: {ok, pid()} | ignore | {error, Error},
|
||||
Error :: {already_started, pid()} | term().
|
||||
start_link(Name, Args, Opts) ->
|
||||
gen_server:start_link({local, ?MODULE}, ?MODULE, Args, Opts).
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
%% @doc init/1
|
||||
%% @end
|
||||
%%--------------------------------------------------------------------
|
||||
-spec init(Args) -> Return when
|
||||
Args :: term(),
|
||||
Return :: {ok, State} | {ok,State,Timeout} | {ok,State,hibernate},
|
||||
Timeout :: integer(),
|
||||
State :: term().
|
||||
init(_Args) ->
|
||||
State = [],
|
||||
{ok, State}.
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
%% @doc terminate/2
|
||||
%% @end
|
||||
%%--------------------------------------------------------------------
|
||||
terminate(_Reason, _Data) ->
|
||||
ok.
|
||||
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
%% @doc handle_call/3
|
||||
%% @end
|
||||
%%--------------------------------------------------------------------
|
||||
-spec handle_call(Message, From, State) -> Return when
|
||||
From :: term(),
|
||||
Message :: term(),
|
||||
State :: term(),
|
||||
Return :: term().
|
||||
handle_call(Message, From, State) ->
|
||||
logger:warning("got ~p from ~p", [Message, From]),
|
||||
{reply, Message, State}.
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
%% @doc handle_cast/2
|
||||
%% @end
|
||||
%%--------------------------------------------------------------------
|
||||
-spec handle_cast(Message, State) -> Return when
|
||||
Message :: term(),
|
||||
State :: term(),
|
||||
Return :: term().
|
||||
handle_cast(Message, State) ->
|
||||
logger:warning("got ~p", [Message]),
|
||||
{noreply, State}.
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
%% @doc handle_info/2
|
||||
%% @end
|
||||
%%--------------------------------------------------------------------
|
||||
-spec handle_info(Message, State) -> Return when
|
||||
Message :: term(),
|
||||
State :: term(),
|
||||
Return :: term().
|
||||
handle_info(Message, State) ->
|
||||
logger:warning("got ~p", [Message]),
|
||||
{noreply, State}.
|
||||
151
_app/src/name_statem.erl
Normal file
151
_app/src/name_statem.erl
Normal file
@@ -0,0 +1,151 @@
|
||||
%%%-------------------------------------------------------------------
|
||||
%%% @author {{author_name}} <{{author_email}}>
|
||||
%%% @copyright {{copyright_year}} (c) {{author_name}}
|
||||
%%%
|
||||
%%% @doc gen_statem template for {{name}} application
|
||||
%%% @end
|
||||
%%%-------------------------------------------------------------------
|
||||
-module({{name}}_statem).
|
||||
-behaviour(gen_statem).
|
||||
-export([start/0, start/1, start/2, start/3]).
|
||||
-export([start_link/0, start_link/1, start_link/2, start_link/3]).
|
||||
-export([callback_mode/0, init/1, terminate/3]).
|
||||
-export([on/3, off/3]).
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
%% @doc start/0
|
||||
%% @end
|
||||
%%--------------------------------------------------------------------
|
||||
-spec start() -> Return when
|
||||
Return :: {ok, pid()} | ignore | {error, Error},
|
||||
Error :: {already_started, pid()} | term().
|
||||
start() ->
|
||||
start([]).
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
%% @doc start/1
|
||||
%% @end
|
||||
%%--------------------------------------------------------------------
|
||||
-spec start(Args) -> Return when
|
||||
Args :: term(),
|
||||
Return :: {ok, pid()} | ignore | {error, Error},
|
||||
Error :: {already_started, pid()} | term().
|
||||
start(Args) ->
|
||||
start(Args, []).
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
%% @doc start/2
|
||||
%% @end
|
||||
%%--------------------------------------------------------------------
|
||||
-spec start(Args, Opts) -> Return when
|
||||
Args :: term(),
|
||||
Opts :: [term()],
|
||||
Return :: {ok, pid()} | ignore | {error, Error},
|
||||
Error :: {already_started, pid()} | term().
|
||||
start(Args, Opts) ->
|
||||
gen_statem:start(?MODULE, Args, Opts).
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
%% @doc start/3
|
||||
%% @end
|
||||
%%--------------------------------------------------------------------
|
||||
-spec start(Name, Args, Opts) -> Return when
|
||||
Name :: atom(),
|
||||
Args :: term(),
|
||||
Opts :: [term()],
|
||||
Return :: {ok, pid()} | ignore | {error, Error},
|
||||
Error :: {already_started, pid()} | term().
|
||||
start(Name, Args, Opts) ->
|
||||
gen_statem:start({local, ?MODULE}, ?MODULE, Args, Opts).
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
%% @doc start_link/0
|
||||
%% @end
|
||||
%%--------------------------------------------------------------------
|
||||
-spec start_link() -> Return when
|
||||
Return :: {ok, pid()} | ignore | {error, Error},
|
||||
Error :: {already_started, pid()} | term().
|
||||
start_link() ->
|
||||
start_link([]).
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
%% @doc start_link/1
|
||||
%% @end
|
||||
%%--------------------------------------------------------------------
|
||||
-spec start_link(Args) -> Return when
|
||||
Args :: term(),
|
||||
Return :: {ok, pid()} | ignore | {error, Error},
|
||||
Error :: {already_started, pid()} | term().
|
||||
start_link(Args) ->
|
||||
start_link(Args, []).
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
%% @doc start_link/2
|
||||
%% @end
|
||||
%%--------------------------------------------------------------------
|
||||
-spec start_link(Args, Opts) -> Return when
|
||||
Args :: term(),
|
||||
Opts :: [term()],
|
||||
Return :: {ok, pid()} | ignore | {error, Error},
|
||||
Error :: {already_started, pid()} | term().
|
||||
start_link(Args, Opts) ->
|
||||
gen_statem:start_link(?MODULE, Args, Opts).
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
%% @doc start_link/3
|
||||
%% @end
|
||||
%%--------------------------------------------------------------------
|
||||
-spec start_link(Name, Args, Opts) -> Return when
|
||||
Name :: atom(),
|
||||
Args :: term(),
|
||||
Opts :: [term()],
|
||||
Return :: {ok, pid()} | ignore | {error, Error},
|
||||
Error :: {already_started, pid()} | term().
|
||||
start_link(Name, Args, Opts) ->
|
||||
gen_statem:start_link({local, ?MODULE}, ?MODULE, Args, Opts).
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
%% @doc callback_mode/0
|
||||
%% @end
|
||||
%%--------------------------------------------------------------------
|
||||
-spec callback_mode() -> Return when
|
||||
Return :: atom() | [atom()].
|
||||
callback_mode() ->
|
||||
state_functions.
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
%% @doc init/1
|
||||
%% @end
|
||||
%%--------------------------------------------------------------------
|
||||
-spec init(Args) -> Return when
|
||||
Args :: term(),
|
||||
Return :: {ok, State, Data},
|
||||
State :: term(),
|
||||
Data :: atom().
|
||||
init(_Args) ->
|
||||
State = on,
|
||||
Data = [],
|
||||
{ok, State, Data}.
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
%% @doc terminate/3
|
||||
%% @end
|
||||
%%--------------------------------------------------------------------
|
||||
terminate(_Reason, _State, _Data) ->
|
||||
ok.
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
%% @doc on/3
|
||||
%% @end
|
||||
%%--------------------------------------------------------------------
|
||||
on(MessageType, Message, Data) ->
|
||||
logger:warning("got ~p from ~p", [Message, MessageType]),
|
||||
{keep_state, Data}.
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
%% @doc off/3
|
||||
%% @end
|
||||
%%--------------------------------------------------------------------
|
||||
off(MessageType, Message, Data) ->
|
||||
logger:warning("got ~p from ~p", [Message, MessageType]),
|
||||
{keep_state, Data}.
|
||||
58
_app/src/name_sup.erl
Normal file
58
_app/src/name_sup.erl
Normal file
@@ -0,0 +1,58 @@
|
||||
%%%-------------------------------------------------------------------
|
||||
%%% @author {{author_name}} <{{author_email}}>
|
||||
%%% @copyright {{copyright_year}} (c) {{author_name}}
|
||||
%%%
|
||||
%%% @doc {{name}} application supervisor
|
||||
%%% @end
|
||||
%%%-------------------------------------------------------------------
|
||||
-module({{name}}_sup).
|
||||
-behaviour(supervisor).
|
||||
-export([start_link/0, start_link/1, start_link/2]).
|
||||
-export([init/1]).
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
%% @doc start_link/0
|
||||
%% @end
|
||||
%%--------------------------------------------------------------------
|
||||
-spec start_link() -> Return when
|
||||
Return :: supervisor:startlink_ret() |
|
||||
supervisor:startlink_err().
|
||||
start_link() ->
|
||||
start_link([]).
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
%% @doc start_link/1
|
||||
%% @end
|
||||
%%--------------------------------------------------------------------
|
||||
-spec start_link(Args) -> Return when
|
||||
Args :: term(),
|
||||
Return :: supervisor:startlink_ret() |
|
||||
supervisor:startlink_err().
|
||||
start_link(Args) ->
|
||||
start_link(?MODULE, Args).
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
%% @doc start_link/2
|
||||
%% @end
|
||||
%%--------------------------------------------------------------------
|
||||
-spec start_link(Name, Args) -> Return when
|
||||
Name :: atom(),
|
||||
Args :: term(),
|
||||
Return :: supervisor:startlink_ret() |
|
||||
supervisor:startlink_err().
|
||||
start_link(Name, Args) ->
|
||||
supervisor:start_link({local, Name}, ?MODULE, Args).
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
%% @doc init/1
|
||||
%% @end
|
||||
%%--------------------------------------------------------------------
|
||||
-spec init(Args) -> Return when
|
||||
Args :: term(),
|
||||
Return :: {ok, {supervisor:sup_flags()
|
||||
,supervisor:child_spec()}} |
|
||||
ignore.
|
||||
init(_Args) ->
|
||||
SupervisorFlags = #{},
|
||||
ChildSpecs = [],
|
||||
{ok, {SupervisorFlags, ChildSpecs}}.
|
||||
141
_app/test/name_SUITE.erl
Normal file
141
_app/test/name_SUITE.erl
Normal file
@@ -0,0 +1,141 @@
|
||||
%%%-------------------------------------------------------------------
|
||||
%%% @author {{author_name}} <{{author_email}}>
|
||||
%%% @copyright {{copyright_year}} (c) {{author_name}}
|
||||
%%%
|
||||
%%% @doc
|
||||
%%% @end
|
||||
%%%-------------------------------------------------------------------
|
||||
-module({{name}}_SUITE).
|
||||
-compile(export_all).
|
||||
-include_lib("common_test/include/ct.hrl").
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
%% @doc
|
||||
%% @end
|
||||
%%--------------------------------------------------------------------
|
||||
-spec suite() -> Return when
|
||||
Return :: [tuple()].
|
||||
suite() ->
|
||||
[{timetrap,{seconds,30}}].
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
%% @doc
|
||||
%% @end
|
||||
%%--------------------------------------------------------------------
|
||||
-spec init_per_suite(Config) -> Return when
|
||||
Config :: [tuple()],
|
||||
Reason :: term(),
|
||||
Return :: Config | {skip,Reason} | {skip_and_save,Reason,Config}.
|
||||
init_per_suite(Config) ->
|
||||
Config.
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
%% @doc
|
||||
%% @end
|
||||
%%--------------------------------------------------------------------
|
||||
-spec end_per_suite(Config) -> Return when
|
||||
Config :: [tuple()],
|
||||
Return :: term() | {save_config,Config}.
|
||||
end_per_suite(_Config) ->
|
||||
ok.
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
%% @doc
|
||||
%% @end
|
||||
%%--------------------------------------------------------------------
|
||||
-spec init_per_group(GroupName, Config) -> Return when
|
||||
GroupName :: atom(),
|
||||
Config :: [tuple()],
|
||||
Reason :: term(),
|
||||
Return :: Config | {skip,Reason} | {skip_and_save,Reason,Config}.
|
||||
init_per_group(_GroupName, Config) ->
|
||||
Config.
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
%% @doc
|
||||
%% @end
|
||||
%%--------------------------------------------------------------------
|
||||
-spec end_per_group(GroupName, Config) -> Return when
|
||||
GroupName :: atom(),
|
||||
Config :: [tuple()],
|
||||
Return :: term() | {save_config,Config}.
|
||||
end_per_group(_GroupName, _Config) ->
|
||||
ok.
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
%% @doc
|
||||
%% @end
|
||||
%%--------------------------------------------------------------------
|
||||
-spec init_per_testcase(TestCase, Config) -> Return when
|
||||
TestCase :: atom(),
|
||||
Config :: [tuple()],
|
||||
Reason :: term(),
|
||||
Return :: Config | {skip,Reason} | {skip_and_save,Reason,Config}.
|
||||
init_per_testcase(_TestCase, Config) ->
|
||||
Config.
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
%% @doc
|
||||
%% @end
|
||||
%%--------------------------------------------------------------------
|
||||
-spec end_per_testcase(TestCase, Config) -> Return when
|
||||
TestCase :: atom(),
|
||||
Config :: [tuple()],
|
||||
Reason :: term(),
|
||||
Return :: term() | {save_config,Config} | {fail,Reason}.
|
||||
end_per_testcase(_TestCase, _Config) ->
|
||||
ok.
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
%% @doc
|
||||
%% @end
|
||||
%%--------------------------------------------------------------------
|
||||
-spec groups() -> Return when
|
||||
Group :: {GroupName,Properties,GroupsAndTestCases},
|
||||
GroupName :: atom(),
|
||||
Properties :: [parallel | sequence | Shuffle | {RepeatType,N}],
|
||||
GroupsAndTestCases :: [Group | {group,GroupName} | TestCase],
|
||||
TestCase :: atom(),
|
||||
Shuffle :: shuffle | {shuffle,{integer(),integer(),integer()}},
|
||||
RepeatType :: repeat | repeat_until_all_ok | repeat_until_all_fail |
|
||||
repeat_until_any_ok | repeat_until_any_fail,
|
||||
N :: integer() | forever,
|
||||
Return :: [Group].
|
||||
groups() ->
|
||||
[].
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
%% @doc
|
||||
%% @end
|
||||
%%--------------------------------------------------------------------
|
||||
-spec all() -> Return when
|
||||
GroupsAndTestCases :: [{group,GroupName} | TestCase],
|
||||
GroupName :: atom(),
|
||||
TestCase :: atom(),
|
||||
Reason :: term(),
|
||||
Return :: GroupsAndTestCases | {skip,Reason}.
|
||||
all() ->
|
||||
[my_test_case].
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
%% @doc
|
||||
%% @end
|
||||
%%--------------------------------------------------------------------
|
||||
-spec my_test_case() -> Return when
|
||||
Return :: [tuple()].
|
||||
my_test_case() ->
|
||||
[].
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
%% @doc
|
||||
%% @end
|
||||
%%--------------------------------------------------------------------
|
||||
-spec my_test_case(Config) -> Return when
|
||||
Config :: [tuple()],
|
||||
Reason :: term(),
|
||||
Comment :: term(),
|
||||
Return :: ok | erlang:exit() | {skip,Reason} | {comment,Comment} |
|
||||
{save_config,Config} | {skip_and_save,Reason,Config}.
|
||||
my_test_case(_Config) ->
|
||||
ok.
|
||||
|
||||
Reference in New Issue
Block a user