Posts Tagged ‘Ruby’

RSpec and Autotest

Friday, March 30th, 2007

I am getting all parts of my Rails development environment settled. In addition to vanilla Rails, I am currently using RSpec, Selenium and Autotest. I am seriously considering Haml and Sass as well.

When googling arounf to learn more about Autotest, I realized that people are using together with Growl. It works out-of-the-box with Test::Unit, but RSpec needs a little tweaking. I took the basics from here and modified to my liking. The following is what my .autotest looks like.

 
module Autotest::Growl
  def self.growl title, msg, img, pri=0, stick=""
    system "growlnotify -n autotest --image #{img} -p #{pri} -m #{msg.inspect} #{title} #{stick}"
  end
 
  Autotest.add_hook :ran_command do |at|
    puts "at: '#{at.results}'"
    output = at.results.slice(/(\d+)\s.*specifications?,\s(\d+)\s.*failures?/)
    puts "out: #{output}"
    if output =~ /[1-9]\sfailures?/
      growl "Test Results", "#{output}", '~/Library/autotest/rails_fail.png', 2 #, "-s" 
    else
      growl "Test Results", "#{output}", '~/Library/autotest/rails_ok.png'
    end
  end
end
 

Ruby Code Completion in TextMate

Tuesday, January 30th, 2007

For some reason, there has been very little fuss over the fact that TextMate now offers code completion for Ruby using the rcodetools gem. It is all still in svn, so you have to check it out manually.

Log for r6455

[NEW] The Ruby bundle now includes an rcodetools-backed completion command on option-escape.  This command is capable of very accurate completion for any accessible Ruby objects and methods, without needing to see you type it first (as TextMate’s default completion requires).

Javaforum in Stockholm Wrap Up

Wednesday, November 22nd, 2006

I spent yesterday evening at Javaforum. Ola Bini held a great presentation of JRuby that really showed what can be accomplished today and what we can expect in the future.

Ola is not only an über hacker, he is a great guy too. When asked what work is done with Ruby in Sweden today, he was kind enough to mention the work we’ve done at Valtech with Rails, which of course got him a well deserved beer later.

The guys from Interface 21 did a so-so job presenting Spring AOP. I might be biased as I have been in AOP-land and left it, but in my opinion their presentation skills were far better than the actual content.

During after-beer Ola and I discussed the state of Java and agreed that the greatest part of the Java platform is the JVM. It will most probably survive Java the language and be a platform for a multitude of languages. It was therefore funny to read Mike Bowlers blog post today about exactly the same thing.

All in all a good evening.

Kent Beck on Ruby

Wednesday, August 9th, 2006

Kent Beck on Ruby: “

I always knew one day Smalltalk would replace Java. I just didn’t know it would be called Ruby.
– Kent Beck

Blaine Buxton links to this quote at ozmmdotorg.”

(Via Mike Bowler’s thoughts.)

It is time to stop listening to James Gosling

Saturday, March 11th, 2006

It seems that Sun is using James Gosling to spread FUD regarding any technology that competes with Java. He created Java, and he is a techie and techies have high standards and are always honest - right?

He came out slinging against Harmony a year ago, and now he is at it again with Ruby and PHP:

PHP and Ruby are perfectly fine systems, but they are scripting languages and get their power through specialization: they just generate web pages. But none of them attempt any serious breadth in the application domain and they both have really serious scaling and performance problems.

He is either grossly misinformed or he is making things up. Either way it is time to stop listening. Too bad.

(Via Loud Thinking.)

Larry: Chuck Norris Facts

Monday, January 30th, 2006

Really funny:

A list of facts about Chuck Norris

(Via Planet Ruby on Rails.)

Intial report from Javapolis

Wednesday, December 14th, 2005

So I arrived yesterday to Antwerpen, and have just sat through the keynote. It was basically a shameless plug battle between Sun and BEA. The most interesting thing was Bill Roth talking about WebLogic “in the coming years” supporting “languages that might take off”. This is in line with what Jon wrote some time ago. Rails on WebLogic? Could be interesting, if not for no other reason but to gain a wider acceptance for Rails.

Really good books

Thursday, December 1st, 2005

While at Lecando, I was quite proud of the library of computer books we assembled oveer the years.

These days as a consultant for Valtech, my employer does indeed have a library, but as I am almost never at the office it is not really accessible.

I have therefore started to buy the books that I find necessary for my daily digital life out of my own pocket so that I can have access to them whenever I want. These are the ones I have got so far:

While looking at the list I couldn’t help but noticing that I really like the Pragmatic books. I am equally surprised that I have so far not felt the urgent need for any of the O’Reilly titles

Ruby and MySQL on Tiger

Monday, October 17th, 2005

Lots of people have had problems with Ruby and MySQL. The ever so pragmatic Rails book links to a popular solution which involves installing the MySQL gem and specifying the path to the MySQL. This did not do the trick for me, and I’ve failed trying different alternatives after that. Today I came across PJ Hyett’s idea of installing Ruby-MySQL from source. It worked like a charm.

Gnome Panel Applet for Luntbuild

Thursday, June 9th, 2005

I’ve created a Gnome Panel Applet to monitor Luntbuild builds. This is basically a spike to try out the Ruby-GTK2 library and the Luntbuild API but it works so I might as well release it.

Download

Ruby on Rails on Ubuntu

Thursday, April 14th, 2005

I feel I just have to try Ruby on Rails, I mean everybody else is doing it and I don’t want to feel left out.

So I started setting it up on my X40 which runs Ubuntu. There is still no deb available for it, you have to use the Ruby Gems system to set it up. I dont know if this is good or bad - it seems like a Ruby CPAN and my feelings towards Perls CPAN are mixed. I once ended up with two Perls on a Red Hat box when using it to set up Request Tracker. Let’s hope Gems works better.

To start out I had to apt-get rdoc and libzlib-ruby. After that it is installed. Whohoo. What now?

Ok rails ~/work/rortest … Bang. Some dependency is missing. Let’s search Synaptic to see what could possibly make it tick.

libwebrick maybe? Nope.
libmysql-ruby? Nope.
eruby? No.
libdbi-mysql. Noo.
libwhatever-ruby. Nothing works.

Maybe there’s some info on their site? Hmm … there are instructions on how to install it on Debian unstable which involves apt-getting the all ruby libraries known to man - but who cares - let’s try that.

Whohoo! It works. Let’s see some of the Ruby love in the browser then - it is indeed there.

Ok. Now for the database tweaking. Why three databases? I guess I’l find out.

Yaml is really, really nice.

Ok, according to the site, all I have left is to develop my Rails application, so I guess that is what I will do. Wish me luck.

Update: There are now instructions for how to set up Rails on Ubuntu.

Hackers & Painters

Monday, April 11th, 2005

Like so many others, I have read Hackers and Painters by Paul Graham. And, surprise, I find it highly recommendable, like everybody else. The following are a few thoughts about I jotted down while reading:

  • Why, oh why, in the name of mad page flipping are the footnotes placed in the back?
  • I am surprised that Pete McBreen of Software Craftmanship fame is not mentioned - in my opinion they are making the same case against “Computer Science”
  • Contrary to common XP belief Paul Graham favors code ownership. Quite unusual in this day and age, and interesting - I need to reflect on it more.
  • His thoughts on developers needing empathy are spot on. Not only for the end users but also for the later developers. It is also better to tell a developer to see things from somebody elses view and document accordingly instead of having him follow the RUP Deliverable Tablets of Stone without reflection.
  • Hosting your own web application - I wish. Companies today still see the intranet as something that should be inside their own, very physical, walls. And I can’t blame them - at Lecando we run our own JIRA, Confluence, SugarCRM etcetera in house. It hit me though when thinking about this - what would we choose if Atlassian offered a hosted JIRA at a competitive price? What if that was the only way they offered their solution? Would JIRA be developed faster since they did not have to worry about releases and customers maintenance problems, or would they spend that time managing the server park?
  • Paul Graham makes a very strong case for capitalism. Whatever your view on politics - I believe that the starting part of the Wealth chapter describing the difference between wealth and money should be taught to all.
  • The parts about Lisp are quite tiresome. And regarding Perl as a higher level language than Java? Please.
  • With “Partisans of permissive languages ridiculing the other [preventive languages such as Java - my note] as “B&D” (bondage and discipline) languages” Paul Graham wonders what “prevent”-style people say of Perl? At Lecando we normally just say “Perl …” and shake our heads.
  • Paul Graham has a slightly dismissive tone when talking about stuff like object orientation, static typing etcetera which can get on your nerves if you are a Java head.
  • I get the feeling that he sees Java people the way Java people see VB people. Prejudice! :)
  • He suggests that pointy-haired bosses select Java for programming projects. Since I would select Java for many programming project, would that make me pointy-haired?
  • He does explain, perhaps unintentionally, Javas success by emphasizing the importance of existing libraries for a programming language to succeed. Hibernate, Lucene et cetera anyone?.
  • When he mentions the importance of efficiency and the ability to rewrite code I believe he is right. But, I can be dead wrong, I imagine Paul being a Emacs hacker, and if you still only use Emacs, it is sure easier to write code in Python, Ruby etc. But in Java land there is this neat thing called refactoring IDE’s - Eclipse, IDEA and the lot. My problem is that it is hard returning to Emacs after using a code-completing, refactoring IDE like IDEA.
  • I guess I have to learn Lisp to see what the fuss is all about

Edit: Fixed typos

Saying hello to our old friend Ant

Friday, February 11th, 2005

Alef Arendsen ponders on whether to switch from Ant to a Ruby build tool. At Lecando we just this week finished migrating away from a Ruby based build system we called Raven. Our former employee HÃ¥kan speaks in his blog entry from way back then about the enthusiasm we shared. Of course, HÃ¥kan speaks of our migration from Maven, the build tool from hell of which one should not speak.

So we’ve now gone full circle - Ant - Maven - Raven - Ant. So what happened and why?

Our build.xml used to be a trillion lines long and quite unmaintainable. When we first saw Maven we thought “Easy targets due to standard directory organization, automatic dependency downloads and we will probably read that really nice webpage thingy very often. Way cool, we want that”. Since we never have hesitated to throw new fun explosive stuff onto our e-learning fire we pushed all our directories around, picked up the ball and ran with it.

I looked at our old project.xml file today. Man, that thing is ugly. As Cedric points out, Maven is really four languages, and Jelly is one of them. Ouch.

At that time we were bitten by the Ruby bug due to a number of reasons, two of them being Jon, head chef of Damage Control who had just left us for new frontiers, and Anders Bengtsson who used to work for us but is still a good friend of some of the guys. This combined with our craving for a shiny new build system made us roll up our sleeves and start to build our own build system in Ruby, Raven.

When you start to build a new file system you most probably start with the easy pieces. “Let’s see … compile? That’s good - we need to compile in our projects. And we can set our classpath in a really non-obtrusive way. Oh, this feels so good, I’m glad we’re doing this. And next … Test? Awesome, we’ll be done in no time.”

… A little later …

“OK. it is not a good as in the beginning but we’ll refactor it. Now we just need to build the docbook docs, package the war, pack it up in a ear, zip that up with all external docs and whatnots and we’re done.”

Spoiler: The resulting build was as hard to maintain as the previous ones had been, albeit in a prettier syntax.

I believe it is exactly the same thing as when you start out with your Ant build file. As long as you’re setting up the compile and test part everything is really clean, but when you get into the specifics that is needed for your app like for example signing an applet - we used to do that - things get dirty. And it does not matter what language you do it in, it is complicated even in plain English, or Swedish. (”Take those files and sign them with that certificate file over there to produce an applet as a jar for Netscape, and when your done you take the same files and sign them again, but this time with that certificate file over there for Explorer, and, oh yeah, make it a CAB file. Don’t mess up or the browser barfs”)

While we were doing this, things happened in Ant land. Imports and Macrodefs solved a lot of problems, making build files readable. IDEA even provides code completion and refactoring support for Ant. As you might suspect, we did not have that for Raven. We slowly accepted fate and began the walk back into XML. However, among the brackets are a few goodies in addition to the ones above.

Ants platform independency is king. Visar, our designer guy, can run the app from his Windows box as well as we do on our Linux ones. I know, Ruby is supposed to be platform independent, but unfortunately it works in the same way Python does it - almost.

We have even rolled our own CruiseControl in Ruby. We really did not like CruiseControl two years ago so we might not use it now either, but at least now we have the choice. I’ve read a lot of good things about it recently and if it is good enough for Mike Clark it must be good enough for us as well.

To sum it up, Ant is a standard which in itself might not be the best thing at all, but with all the support for it it certainly comes out on top for us.

IDEA vs Eclipse

Sunday, August 31st, 2003

At Lecando we are long time licensees of IntelliJ IDEA. But since Eclipse is free and open source is good, I have given it a serious try in my spare time. After 2 months I’ve returned to IDEA. Much faster, more intuitive and less weird views of everything (”Do you want to switch to the Java view for your Java project?” Uhhm … yes?). As Jon once said: Eclipse is bloat, IDEA is not.

Eclipse strongest points in my view are incremental compiling and a nice JUnit integration.

The worst part though: it is slow. Really. If you’re an Eclipse user and don’t agree, try IDEA out and see for yourself.

Also, I find it not really focused on what is trying to do. It is a Java IDE, but with it’s micro kernel architecture it can also handle your PHP, Python, Ruby and it can be that IDE toaster oven you always wanted. But editing anything else but Java is done in a very basic fashion. JEdit does IMO a better job of being your versatile handle-everything editor.