labria’s ruby blog

random ruby/rails stuff

Archive for the ‘Erlang’ Category

erlgen deprecated.

leave a comment

I created my erlgen tool because I lacked something to do the job. Now i'm deprecating it, because such a tool was written.

Welcome Rebar! It's not simpy a generator, but a swiss knife for the complete erlang application lifecycle. Generation, dependencies, building, dialyzer, eunit, release, you name it — Rebar does it.

And to complete the beauty of it: it's written in erlang and has no dependencies itself except erlang. (for all of you ruby haters out there =))

Written by labria

June 20th, 2010 at 12:08 pm

Posted in Erlang

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

My first working Erlang code.

leave a comment

I wrote my first working bit of Erlang code. Wasn't much code, actually. Here it is:

<erl>
out(A) ->
    {ok, Challenge} = queryvar(A,"hub.challenge"),
    {html,io_lib:format('~s', [Challenge])}.
</erl>

Wow... my highlighter doesn't even support Erlang! now it does

This a complete and finished piece of code, yes. If you heard of PubSubHubbub — that's the code to confirm all subscriptions in async mode.

The funny thing about it is the amount of code I would user to do the same in Rails/Sinatra/Whatever + erb:

<%= params["hub.challenge"]%>

Written by labria

September 15th, 2009 at 1:13 am

Posted in Erlang