Intro
Rebar is a great command line tool for building your Erlang apps. It was developed by guys from basho
http://basho.com/. If you want to build Erlang app or module you can skip a lot of config / boilerplate code but using rebar.
Wait what? How do i get it ?
To obtain rebar all you have to do is clone source using
1
|
|
after obtaining source go into directory and bootstrap it.
1 2 |
|
This will build rebar script if everything is successful. Last thing i suggest is adding this directory to your path.
1
|
|
So you will be able to use it like other command lines tools from “global namespace”.
Now you should have working rebar installation. Just to test that everything is ok you can run rebar
like this.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|
How do i use it @_@ ?
Two most important things you can generate using rebar
are applications and nodes.
To generate application you just need to create app directory and run rebar create-app
command like this.
1 2 3 4 5 6 7 |
|
This has created application scaffold with ready to go supervisor. This is ready to go!
to compile it just run rebar compile
Me gusta
This is all fine but that don’t eliminate a lot, sweet things are behind the corner :).
eunit
Rebar enables you to use easy eunit testing framework within your code. Like we did it here http://no-fucking-idea.com/blog/2012/03/23/using-eredis-in-erlang/. To do it just run rebar compile eunit
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
|
coverage
Also if you will fiddle with rebar.config
and set some variables like this:
1 2 3 4 5 |
|
you can get test coverage generated in .eunit
folder. but this is just the beginning. lets look at it.
1 2 3 4 5 6 7 8 9 10 11 12 |
|
dependencies
Last thing i want to mention is dependencies, i love this feature from rebar
. You can add dependencies and rebar will do all the magic for you :). just open your rebar.config
and add thme like this:
1 2 3 4 5 6 7 8 9 10 |
|
Whenever you will type rebar get-deps
he will download all dependencies and install them into deps
directory. This makes developing applications using things like mochiweb really easy!
Summary
I love this tool, it makes learning and development in Erlang
much easier and more rewarding experience. I hope this help you a bit :). Cheers!