Return to 10to1.be

Under the Hat


Category: Ruby

Vim Flog Plugin

13 Feb 2011

A couple of days ago I found a nice Vim plugin to show the flog scores of your Ruby code insise your Vim editor.

But because it wasn't really displayed the way I wanted, I forked and customized it.

Now what is Flog?

Flog shows you the most torturous code you wrote. The more painful the code, the higher the score. The higher the score, the harder it is to test.

For more information on the scores, you can read some interesting blog posts here and here.

Vim Plugin

Here is a screenshot of what flog integration looks like in Vim:

Vim Flog Plugin

As you can see you now always have a number in front of each def block. This number is the flog score, the higher, the more complex your code is.

In case you would like to use it, you can install it by following these steps.

Credits

All the credits for this plugin go to @skammer because he initially wrote the plugin, I just jumped on it and changed it a bit.

Emacs

In case you're using emacs, Piet recommends using the Emacs Ruby Complexity Plugin.

Resources

Secret pictures (SPIC)

27 Apr 2010

A couple of weeks ago, ruby-play was imminent and in such a case one should always try some new things. Heroku is hot, so it had to be something I could deploy on Heroku. Sinatra 1.0 was released, so it had to be something using Sinatra.

What else? S3 is always fun and with that in mind I found the CarrierWave gem.

More? Sure. To experiment with something else then ActiveRecord I used Sequel.

Does it blend? Sure!

A new example app was born: SPIC. Spic (secret pictures) allows you to upload files to S3 for your sharing pleasure.

Heroku really is fun to use. One can setup Spic in only a matter of seconds.

git clone git://github.com/atog/spic.git
cd spic
heroku create
git push heroku master
heroku config:add S3_KEY=your_s3_key S3_SECRET=your_amazon_secret S3_BUCKET=your_bucket SECRET=your_own_personal_jesus
heroku open

It was fun. It was short. It is good.

Capfire, post deploy notifications to Campfire

02 Apr 2010

We use github for all our projects, and we use Campfire as our office backchannel. So when we saw this post we (or maybe it was just me, I'm a sucker for this kind of stuff) knew we had to have a way to easily use this on all our projects; so here it is: Capfire

What it does

Besides being a kickass gem name, it sends a message to Campfire each time you deploy an application. In this message is a link to Github's compare-view, so you can easily scan just what has changed since your previous deployment. Since it's being sent to Campfire everyone can take a peek. Great !

Installation

First install the gem:

gem install capfire

First run

script/generate capfire -k campfiretoken -a campfireaccount -r campfireroom

This will add a snippet to your config/deploy.rb to include the capfire capistrano script and will create a file in your home folder named .campfire containing your token, account, room and a configurable message (the parts between ##'s are substituted).

Like this (be careful with your spaces):

campfire:
  account: 10to1
  token: thishastobeyourtoken
  room: General
  message: "I (#deployer#) deployed #application#
 with cap #args# (#compare_url#)"

If you're not sure about this automagically thing, you can do it by hand as well, create the ~/.campfire file and add the following to your config/deploy.rb:

begin
  require 'capfire/capistrano'
rescue Object
  # Don't force other users to install Capfire.
end

Subsequent runs

Since a ~/.campfire file already exists you can just run script/generate capfire to add the snippet to your deploy script in each app. You can run this as much you want it will only add the snippet once. No worries.

If someone else on your team doesn't have capfire installed, he won't notice a thing (but be sure to mock him).

I hope you, dear reader, like it as much as we do :)

Create UML diagrams from the command line

13 Oct 2009

Maybe you know it, maybe you don't but yUML is awesome!

Create and share simple UML diagrams in your blogs, wikis, forums, bug-trackers and emails.

Yesterday I was creating a new class diagram using yUML and besides it's a great product it was a bit cumbersome working in a small textarea and pressing 'Generate!' (all the time). I fired up textmate and created a diagram using the yUML syntax. A couple of minutes later I had ruby script which generated the diagram using yUML by taking a text file as input.

Thanks to Jeweler it's dead easy to create gems and release them to Gemcutter so a yumlcmd gem was born.

Installation

sudo gem install yumlcmd

Usage

yumlme -f your-diagram.txt

Example your-diagram.txt

[Customer]+1->*[Order]
[Order]++1-items >*[LineItem]
[Order]-0..1>[PaymentMethod]

Syntax overview: http://yuml.me/diagram/scruffy/class/draw

Output

yuml-output.png

I hope you like it as much as I do :)


About this blog

You’re reading Under the Hat, a weblog written by 10to1.

Who’s got the mic?