Files
erlang-punch/README.md
niamtokik 1581a6666e update
2022-05-01 18:25:58 +00:00

5.3 KiB

Erlang Punch

Erlang Punch was created at first to help developers to learn Erlang, by offering an easy way to chat with mentor and get helps. Nowaday, Erlang Punch is more an Erlang project manager similar to rebar3, erlang.mk or zx.

Description

Edit a project like if it was a meta data project. To explain a bit more all the project is stored in memory and then, when needed, exported in the desired format (e.g. rebar, zip, makefile).

Next to edit a project we can create it only by using functions call.

Author(s)

Before starting a new project, an author should.be created, if its nit the case, all modification will be anonymous and not signed. An author is defined by its name, email and public key signed with private key. It is used to sign all modules and functions created but also to sign/encrypt all exchange.

ep:author().
ep:author({author, Name, Email, KeyPair}).
ep:author({author, Name, Email, KeyPair}, Opts).

Applications, Modules and Functions

To creates modules and function, we can use an editor, automatically opened by ep or directly craft ou function by using ep functions.

% start the default editor of the system based on EDITOR 
% environment variable. The module is stored in temporary path and let you 
% modify the source. When your edition is done and the code saved, ep
% will import it and create/update the module
ep:edit({module, Module}).
ep:edit({function, Module, Function}).

% create a new application with name Name.
% create a new module named with Name. A module can also use a behavior
% like supervisor, gen_server and gen_statem. Customer behavior can also
% be defined.
ep:create({application, Name}).
ep:create({application, Name, Opts}).

% create a new module
ep:create({module, Name}).
ep:create({module, Name, Opts}).
ep:create({module, Name, [{behavior, supervisor}]).
ep:create({module, Name, [{behavior, gen_server}]).
ep:create({module, Name, [{behavior, gen_statem}]).

% create a new function in specific module. If the module
% does not exist, it is automatically created.
ep:create({function, Module, Name, Body}).
ep:create({function, Module, Name, Body, Opts}).

% compile a module and return its compiled format
ep:compile(Module).

% load a module, if it was not compiled, it will be done 
% automaticaly
ep:load(Module).

% get information about a module, a function or an application
ep:info({module, Module}).
ep:info({function, Module, function}).
ep:info({application, Name}).

% delete a module, a function or an application.
ep:delete({module, Module}).
ep:delete({function, Module, Function}).
ep:delete({application, Name}).

Saving and Commits

Save the current project only save the content without version. Commitng it automatically generate metadata and all required elements like release files and so on.

% save the whole project
ep:save().
ep:save({application, Name}).
ep:save({module, Name}).

% commit the whole project
ep:commit().
ep:commit({application, Name}).
ep:commit({module, Name}).

Indexing and Searching

All function and module created generate automatically default spec, doc and metadata like version, checksum and signature. We can search through thesw info locally or remotely.

% search for specification
ep:search({specification, Spec}).
ep:search({specification, Spec}, Filter).

% search for documentation
ep:search({documentation, Name}).
ep:search({documentation, Name}, Filter).

% search for application
ep:search({application, Name}).
ep:search({application, Name}, Filter).

% search for a module
ep:search({module, Name})
ep:search({module, Name}, Filter).

% search for a function or the content of the function
ep:search({function, Name}, Filter).
ep:search({function, '_', Body}, Filter).

% print help
ep:help().
ep:help({module, Name}).

Import and Export

We can also import functions and modules locally by selecting a path and start to read all erlang module in it. We can also export our project.

ep:import(Path).
ep:import(Path, Opts).

ep:export(Path).
ep:export(Path, Format).
ep:export(Path, Format, Opts).

Distributed Development

Now, we can start a server and connect to other one. We can our project with all information

ep:serve().
ep:connect().
ep:share().
ep:disconnect().

Online Support

If something goes wrong, we can also ask for support. For example a bug ok a function or aomething like that.

ep:message({author, Name, Email}, Message).
ep:chat(Author, Module, function, Message).

Versioning

On versioning. The versionning is done on each module. The format is A.B.C. The default version is 0.1.0 and is incremented by following this process:

C is incremented only when the function body is modified. B is incremented when new function are added or deleted. A is incremented when the interface (exported fonctions) is modified, added or deleted.

To Be Defined

  • project namespace: A project namespace is the project in edition by the author. Because Erlang is distributed, it is possible to have many session on the same instance. A namespace could help other developers to work together on same task without interacting with other project.

FAQ

How to represent project tree?

References and Resources