labria’s ruby blog

random ruby/rails stuff

Erlang application generator

leave a comment

In the ruby world, we're used to code generators. Take rails, or the jeweler gem. When we start a project, we rarely start it from scratch, usually we have a skeleton to start with.

In the hardcore Erlang world, it's different. I found only one erlang project generator, the one bundled with mochiweb. It's nice, but its only purpose is to generate a mochiweb application. What I wanted was a generic project skeleton.

So, to help myself and other erlang users out there, I started the erlgen project. Erlgen is a ruby gem that install the erlgen binary. Erlgen has two functions

  • Generate a skeleton project
  • Generate skeleton gen_server/gen_fsm/gen_event modules

Installation

Erlgen requires you to have ruby and rubygems on your machine. I know it sounds like a strange requirement for a Erlang tool, but it was easier for me to write the tool that way, and ruby is very common nowadays (MacOS has it installed by default)

gem install erlgen 

Usage

To generate a new project simply run

erlgen project_name

To create a gen_server (or fsm, or event):

erlgen --gen_server module_name

Note: if you run it from your project root, it will create the file in the 'src' directory.

That's about all it can do for now, but I'm always open to suggestions.

Written by labria

April 1st, 2010 at 12:49 am

Posted in Erlang

Leave a Reply