Restful lava lamps at Camp?!?
Today we set up a lava lamp feedback from a pulse server across the country. Used the ruby x10 library and _why's camping framework as a simple server taking the request. Pulse has the ability to run a command after the build so we just use curl to call the url on the server with success , failure and error and the server just turns on the appropriate lamp.
This was way too easy and didn't take very long the only problem is that a rouge developer can hit the url by hand and turn the lamps on and off. But who ever heard of developers doing anything like that!
This was my first time actually doing something with Camping and it was very easy my plan is to use mongrel when I actually get a machine to set this up on.
One of my co-workers thinks that they can get a traffic light where yellow means that a build is in progress because Pulse will send notifications on project state changes. Yellow means in progress!!
I also think that a Yahoo widget is in order for this because pulse has an remote interface as well. Maybe I will look at the lava lamp one that hooks into cruisecontrol.
If anyone wants the Camping server it is almost too trivial to publish but here is the gist. The only sneaky thing was the sleep it seems that if you send multiple commands you need to pace yourself.
def turnlight(devicename, command)
sleep(1)
lamp = X10.device(devicename) # Create an X10 device
lamp.send(command)
end
class Buildresult < R '/build', '/build/(\w+)'
def get(status= nil)
if status.nil?
render :index
else
$last_status = status
#need to do the work here
if status == 'success'
turnlight('a1', :on)
turnlight('a2', :off)
@message = 'Passed Build set'
else
turnlight('a1', :off)
turnlight('a2', :on)
@message = 'Failed build set'
end
render :buildresult
end
end
end
This definitely has been the bright spot in the week of working on high level designs in word.
Thanks to the prags for the idea. The main problem is the time that it takes to heat up the lamps which is why a traffic light is being proposed. And one person even wants an alarm to sounds. This could get ugly, stay tuned.....

1 Comments:
Ruby rules!!
Post a Comment
Links to this post:
Create a Link
<< Home