Ruby-usb gems

Posted by aslak.hellesoy

I’ve packaged ruby-usb as gems, available both for Windows an *nix/linux/os x

gem install ruby-usb # On *nix/linux/os x you must first install Lib-USB

At one of the projects in BEKK we bought a Betabrite Prism sign to display the status of builds. Getting the Betabrite Gem to work via USB on Windows was a bit of a challenge. I got around it, so I’d like to share it with others.

The first hurdle was to get Ruby-usb to work on Windows. Ruby-usb is a Ruby library that uses the Lib-USB C library. Ruby-usb wasn’t available as a binary gem (with compiled C extensions), so I figured I had to make one myself. Luckily there is a Windows port of Lib-USB, and I decided to try to build Ruby-usb’s C extensions against that library.

After a lot of reading and trial and error I finally realised I had to build Ruby-usb’s C extensions with MinGW and MSYS. I even had to build Ruby itself with MinGW/MSYS in order to get rbconfig to work. These tools are great alternatives to Cygwin, as they produce “pure” win32 binaries.

With a working Ruby-usb gem for Windows I tried out the Betabrite gem, and found a little bug that has now been fixed.

So I ended up having to fork Tanaka’s original Ruby-usb project. The code is on Gitorious and the Gem on Rubyforge. Forking is something I hate to do, but I haven’t been able to get in touch with Tanaka, and it seemed like the only way to publish Ruby-usb as gems.

Matz is coming to Oslo!!

Posted by aslak.hellesoy

The creator of Ruby, Yukihiro Matsumoto is coming to RubyFools Oslo on April 3-4 2008. This is fantastic news – I’m reaqlly looking forward to that. If you haven’t signed up for the conference, hurry up! There are only 150 seats available. (The program will be updated soon with Matz’ talk).

I’m psyched!

RubyFools Oslo 1

Posted by aslak.hellesoy

Organising conferences is fun. I’m helping Trifork organise Norway’s first ever Ruby conference – RubyFools Oslo and BEKK is the main sponsor.

We haven’t finished the agenda yet, but it will be similar to the RubyFools Copenhagen conference which takes place two days before the one in Oslo.

There is also a discussion going on over at irb.no. (That btw is Norway’s biggest Rails site – both in terms of users and features).

I hope to see you there!

Upcoming conferences

Posted by aslak.hellesoy

We’re soon done with 2007, and so far my conference agenda (where I will speak) looks like below. I have a couple more proposals in the pipe that haven’t been approved yet.

February 12th – Software 2008 – Oslo

I’ll be talking about what agile means in 2008 – which really depends who you ask. I was asked, so this will be my story, and I’ll talk about what agile is not too.

Here in Norway the term for agile is “smidig” and one of my new year resolutions for 2008 is actually to stop using that word in conversations, because I cannot expect people to understand what I mean by it. Likewise, when I hear others using the word I feel more and more uncertain about what they mean (unless I know them well). I’m going to start asking people what they mean when I hear “agile” and “smidig”. How annoying :-)

March 14th – QCon – London

QCon is one of those “new” interesting conferences that I have yet to attend. I’ve been asked to do a Ruby tutorial in The Rise of Ruby track. I haven’t been to London for a couple of years, and I’m really looking forward to some pints of Pride with old friends and colleagues.

April 2nd – RubyFools – Copenhagen

This is Denmark’s first Ruby conference, and the agenda looks really impressive (except for this talk). I’m also cooperating with the organisers to make this a road show where the 2nd stop is Oslo from April 3rd-4th. This is going to be fun!

Early november – Smidig 2008 – Oslo

The Smidig 2007 conference was a smashing success with about 250 participants. We got so great feedback that we’re definitely arranging this next year, and we’re aiming for over 500 people this time.

Planning Poker timer with configurable colour transitions

Posted by aslak.hellesoy

I started out writing Aslak Hellesøy’s Planning Poker Timer for (you guessed it): Planning Poker.

We’re going to use the same timer to make speakers stick to their alotted 10 minutes at a lightning talk/open space conference I’m organising with other agile enthusiasts next week.

Johannes Brodwall (who’s one of the other organisers) suggested that the timer should go red when there is three minutes left and black when time is up.

So here you go – it’s now a whole lot more tweakable, and it’s got nice Scriptaculous transitions too.

.NetSpec

Posted by aslak.hellesoy

RSpec is inspiring a lot of open source developers to write BDD frameworks. The last one on the scene is Erlend Oftedal’s .NetSpec

It builds on Microsoft’s unit testing framework which is interesting from a tools perspective.

In-browser editor for RSpec stories

Posted by aslak.hellesoy

Try it out here, but please read on…

David (with the help from Pat Maddox and the RSpec list) has done some absolutely phenomenal work on RSpec lately, allowing executable user stories to be expressed in plain text. The plain text format of user stories is so simple that it should be easy to train non-programmers to write them. This is what has made Fit and FitNesse such useful and popular tools.

RSpec user stories are built up by scenarios, which again are built up of “canned steps” – or Givens, Whens and Thens. When the number of canned steps grows, it can be hard to edit a text file, because it can be hard to remember the exact wording of a step (and if the wording isn’t exact, it won’t work).

I’ve created a prototype for a browser based story editor. It has autocompletion for adding of new steps and in-place editing of parameters to existing steps. Steps can also be reordered.

The idea is that domain experts can work with this tool to add more stories, scenarios and steps and save them. The same tool would also allow users to run the stories and get the results back. Very much like FitNesse does, but adapted to RSpec and with a (hopefully) better user interface.

So far I’ve only fiddled with the browser/Ajax side of things. You can’t actually use this thing yet – but it’s a start.

My first conference! Smidig 2007

Posted by aslak.hellesoy

I’ve attended and spoken at dozens of conferences, but never organised one myself.

So I got together with some folks from the agile movement in Oslo and set up Smidig 2007

It’s a 2 day conference with a half day of Lightning Talks and a half day of Open Space each day. So far we have 170 people signed up and 20 sponsors. We’re aiming for a good mix of techies and non-techies, customer types or vendor types and the main topic is agile software development. This is going to be fun!

Planning Poker Timer

Posted by aslak.hellesoy

A few months ago one of my colleagues, Christer Løvaas, brought a couple of old-fashioned hour glasses (minute glasses, really) to a release planning meeting. -A red one with one minute and a blue one with two minutes.

We used these to timebox the time spent on estimating each story. We had set a goal of spending maximum three minutes per story, including discussion and planning poker. We were estimating a huge backlog, so this was absolutely necessary in order to get through as much of it as possible in one day. (What a day).

A couple of weeks ago I was facilitating two all-day release planning/planning poker workshops, and I brought the hour glasses with me. This time we were facing exactly the same problem as the first time: It was so easy to forget turn the hour glasses or realise when the sand had run out! So we repeatedly spent more time on each story than we had decided.

So I sat down in the lunch and wrote Aslak Hellesøy’s Planning Poker Timer. Props to Kristoffer Dyrkorn for fixing some IE bugs.

It’s a big digital countdown clock that switches from green to red and plays a bell when time is up. Try it out and let me know how it goes.

FunFX: Functional testing for Flex

Posted by aslak.hellesoy

Here is something on the bright side…

Peter Motzfeldt, a BEKK colleague, has released FunFX, a functional testing framework similar to Watir and Selenium, but with Adobe Flex applications as the target platform.

Flex is a very interesting platform (so interesting I’ll have a tutorial about Flex and Rails at RailsConf Europe with Børre Wessel from Adobe). If you’re there we’ll try to give you a sneak peak of FunFX too.

Any application that is based on a UI technology that lacks an affordable, scriptable and easy to use functional testing tool represents a huge risk in terms of maintenance and evolution. So far FunFX seems like the only functional testing for Flex tool that fits the bill of “affordable, scriptable and easy to use”, so I encourage all you Flex/Ruby folks out there to try it out and help make it better.

FunFX is written in Ruby. It was Peter’s first ever experience with Ruby, so there is room for improvement, but the most important problem is solved, namely the Ruby->Flex integration part.

Rails adoption world wide 2

Posted by aslak.hellesoy

If we look at the number of rails developers per capita we get the following distribution:

Update Aug 29 2007: Raul Murciano told me Spain was missing, so I added that.

Denmark (100.0% : 64/5.4 mill)
 
New Zealand (66.15% : 33/4.2 mill)
 
Sweden (63.02% : 68/9.1 mill)
 
Ireland (56.06% : 28/4.2 mill)
 
Australia (52.52% : 130/20.9 mill)
 
Netherlands (49.67% : 96/16.3 mill)
 
Switzerland (48.72% : 43/7.4 mill)
 
Canada (47.12% : 183/32.9 mill)
 
United States (41.32% : 1474/302.5 mill)
 
Finland (38.32% : 24/5.3 mill)
 
United Kingdom (38.31% : 272/60.2 mill)
 
Belgium (37.3% : 46/10.4 mill)
 
Norway (33.77% : 19/4.7 mill)
 
Israel (32.02% : 27/7.1 mill)
 
Portugal (27.94% : 35/10.6 mill)
 
Singapore (22.94% : 12/4.4 mill)
 
Spain (22.44% : 120/45.1 mill)
 
Austria (20.28% : 20/8.3 mill)
 
Germany (18.93% : 184/82.4 mill)
 
Czech Republic (17.31% : 21/10.2 mill)
 
Poland (15.34% : 69/38.1 mill)
 
France (14.55% : 110/64.1 mill)
 
Hungary (12.68% : 15/10.0 mill)
 
Argentina (10.29% : 48/39.5 mill)
 
Ukraine (8.44% : 46/46.2 mill)
 
Romania (7.91% : 20/21.4 mill)
 
Brazil (7.85% : 173/186.8 mill)
 
Italy (6.45% : 45/59.0 mill)
 
Malaysia (4.37% : 14/27.1 mill)
 
South Africa (3.49% : 20/48.5 mill)
 
Venezuela (3.06% : 10/27.6 mill)
 
Russia (3.03% : 51/142.4 mill)
 
Philippines (2.39% : 25/88.7 mill)
 
South Korea (2.11% : 12/48.2 mill)
 
Japan (1.65% : 25/127.7 mill)
 
Turkey (1.58% : 14/74.8 mill)
 
Mexico (1.23% : 15/103.2 mill)
 
India (1.08% : 150/1169.0 mill)
 
Indonesia (0.43% : 12/231.6 mill)
 
People's Republic of China (0.31% : 49/1319.0 mill)
 

Two sessions at RailsConf Europe

Posted by aslak.hellesoy

Both of my RailsConf Europe sessions were accepted.

I’ll be doing two 3-hour tutorials. One with Børre Wessel on “Using Adobe Flex with Rails” and another one with David Chelimsky – “A (1/2) Day of Behavior-driven Development on Rails”.

This should be fun!

JRuby << RSpec

Posted by aslak.hellesoy

The JRuby team announced at RailsConf 2007 that they will bundle RSpec with JRuby when it goes 1.0. JRuby will only ship with two gems (Rake and RSpec), so I’m extremely proud of being a developer of one of the lucky two, because JRuby is going to be big.

RSpec on JRuby means that the wonders of RSpec will soon be available for Java app developers (as well as JRuby/JRuby on Rails developers), so you can do things like this:


describe Bowling do
  before(:each) do
    @bowling = Bowling.new
  end

  it "should score 0 for gutter game" do
    20.times { @bowling.hit(0) }
    @bowling.score.should == 0
  end
end

And continue implementing the production code in Java:


public class Bowling {
    public void hit(int pins) {
    }

    public int score() {
        return 0;
    }
}

An important step for JRuby adoption, because this will let Java developers get their Ruby feet wet without having to deal with tons of red tape.

Switched to Mephisto

Posted by aslak.hellesoy

Typo suddenly started dying on me over at Mediatemple, so I finally upgraded to Mephisto. Actually, I tried Mephisto here a while ago, but it wasn’t compatible with Ruby 1.8.2, which is all you get at Mediatemple’s Grid Server. Luckily for me Mephisto now runs on Ruby 1.8.2 again!

Some of my articles won’t read well until I do some more tweaking, and the Atom feed at Feedburner needs to be updated. I’ll fix that in a couple of weeks.

Build Pattern: Immediate test failure notification

Posted by aslak.hellesoy

Context

You have a continuous integration (CI) system with a long execution time – 10 minutes or more. It may be the “full build” in Fast build/full build or the only build – it doesn’t matter. Most of the CI cycle time is spent running automated tests, and the CI system is not sending notifications before all tests have run – regardless of intermediate failures.

The team wants to be notified about a test failure as soon as it happens. The team also wants to get enough information to be able to start fixing any failing tests without having to wait for the CI system to complete the current cycle.

Solution

  1. Add failure notification capabilities into the test framework.
  2. Make test results easily available before the full test cycle has completed.

There are several ways to do this. I will present a couple of alternatives for each of these points:

Failure notification in the test framework

First of all – I recommend lamps and sounds as notification mechanisms.

You’ll have to understand the internals of your test framework (JUnit, Fitnesse, RSpec, what have you) and hook into the place where test failures are recorded. Once you find out how to write and enable a “failure hook” in your test framework, write one that sends out notifications. You have at least two options here.

Reuse the CI system’s notification gear

Most CI systems have several notification mechanisms built in. If the CI system is open enough you can either reuse some of its notification code, or you can talk to it over some protocol. If not, tell your CI tool vendor about this pattern so they can implement it.

Roll your own

It’s not that hard really – this is what I did. For lamps I can recommend heyu or some other X11 command line tool/api. For sounds I recommend win32/sound or the Java Sound API

Example (using RSpec)

(Usually Rspec is super fast, but on one of our current projects we’re using it to run a truckload of Watir).


require 'win32/sound'

class Spec::Runner::Reporter
  alias old_spec_finished spec_finished
  def spec_finished(name, error=nil, failure_location=nil)
    if(error && !@notified)
      # This is a little wrapper around Net::SSH
      linux_box do |box|
        box.cmd "heyu on A2" # red
        box.cmd "heyu off A1" # green
      end
      Win32::Sound.play(File.dirname(__FILE__) + '/sounds/pacman_dies.wav')
      @notified = true
    end
    old_spec_finished(name, error, failure_location)
  end
end

Make test results easily available before the full test cycle has completed

When developers see the red lamp and hear pacman die they’re dying to fix the problem – and they want to see the test results although the whole test suite is still running.

Most decent automated test tools write results to one or more text files on disk – little by little as tests progress. All you need is to serve these files with a web server. That’s easy with Ruby’s built-in WEBrick.


require 'webrick'
s = WEBrick::HTTPServer.new(
  :Port => 80,
  :DocumentRoot => "path/to/where/test/results/are/written" 
)
trap("INT") { s.shutdown }
s.start

Just make sure this server is running all the time.

Motivation

The same as the motivation in Fast build/full build