Setup a Ruby on Rails Project Using the Lighthouse API With ActiveResource

As you might have already guessed, I’m constantly striving for the simplest yet most optimal process for running both an agile development team and agile web operations. People come first, then the procedures followed by the people and finally, the tools those people use.

Since tools supporting the agile development process have the lowest priority for me, they need to do their job well and get out of my way. It means they have to be as simple yet as powerful as I require. I soon realized this is not an easy requirement to fulfill.

Frustrated with the current tools for agile project management, I did a spike to find out whether it would be feasible to build my own tool and discovered some promising ideas. With my current workload, I’ve lowered the priority of building my dream tool, but I want to share my initial spike findings with you using the lighthouse API with ActiveResource. Simple and basic, it shows how easy it is to get started using a good API with a nice ruby wrapper. The example below didn’t take more than half an hour to build. Not too bad – especially as its already able to manage projects, users, and tickets (a.k.a Stories) including history and tags.

Get started with your basic ruby on rails app (using rails 2.1)

mysqladmin -u root create lightboard_development
rails lightboard

Install the Lighthouse API Ruby wrapper as a plugin

script/plugin install http://ar-code.svn.engineyard.com/lighthouse-api/

Ouch, The Web Application Does Not Start

To avoid a problem like this:

/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:115:in
  `qualified_const_defined?':
  "Plugins::Lighthouse-api::Lib" is not a valid constant name! (NameError)

you have to rename the plugin from lighthouse-api to lighthouse_api (mind the dash “-” vs. the underscore “_”)

	mv vendor/plugins/lighthouse-api vendor/plugins/lighthouse_api

And as ActiveResource is now part of rails, you can get rid of the superfluous vendor directory

	rm vendor/plugins/lighthouse_api/vendor

Configure Access to Your Lighthouse Account

Of course, you need an account at http://www.lighthouseapp.com first πŸ˜‰

I put my account and token config into a custom inizalizer config/initializers/lighthouse_api.rb

	Lighthouse.account = 'myaccountname'
	Lighthouse.token = 'myverylong-lighthouse-token'

Using The API is Trivial

script/generate controller story_board index

Then, your story_board_controller could use the API like so:

class StoryBoardController < ApplicationController
 include Lighthouse
 def index
   @projects = Project.find(:all)
 end
end

Now you can show all the projects of your account in the view:

In index.html.erb:

 "project", :collection => @projects %>

And in _project.html.erb:


UI Would be The Most Complex Part to Build

Using the API as a backend, I get a lot of functionality for free. What I miss from the API is the support for managing attachments, but that’s not the most important feature. The main efforts would lay in building the UI. Let’s see when the pain with other tools becomes intolerable enough to finally tackle building my own πŸ˜‰

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.