Wednesday, February 07, 2007

Reconsider method_missing

Assaf notes an interesting problem that arose from the use of method_missing. In his case what passed in testing failed in production because of an unexpected interaction between Rake and SFTP's method_missing based delegation. I think that the problem with method_missing is that it's a neat trick and, once you have it, it's tempting to use it... even when there are better solutions available (which, outside of Proxies, I think there usually are).

On the other hand Jamis find a cool use of method_missing within ActiveRecord::Base:

Calling super forces the superclass, ActiveRecord::Base, to be sent the notificationaddress message, which it won’t understand. This causes methodmissing to be called on AR::Base, which looks for the notificationaddress attribute in the record’s attribute set. If that has not been set, it will be nil, in which case we then default to the emailaddress value.

I guess the thing is to weigh up the benefits and decide if the potential brittleness of a method_missing solution is worth it.

07/02/2007 10:50 by Matt Mower | Permalink | comments:
More about:

Creating a new Rails application in Subversion

Every time I come to start a new Rails project I end up looking for instructions on putting the project in svn, removing log files and so on. Today I came across a bash script by Akhil Bansal that does this and is quite neat.

However I hate being prompted for stuff I can just as easily put on the command line and I hate having to remember to construct file:// URL's when working locally so I converted Akhil's script into Ruby, added William Morgan's Trollop library to process command line arguments and automatically convert relative file paths into fully qualified file:// URLs.

Now I can do this:

Alia:~/Projects/cominded matt$ svnrails --url ./localrepos/project/trunk project
Repository path: file:///Users/matt/Projects/cominded/localrepos/project/trunk
Creating rails application: project
Importing application into repository
Replacing application with SVN version
Removing log files
Removing tmp files
Moving database.yml to database.example.yml

and life is good.

Here is my script, svnrails. Use svnrails --help to see how to pass username & password if required. Note that I have only tested it with a local repository so far.

07/02/2007 13:04 by Matt Mower | Permalink | comments:
More about:

Jobs on a DRM-free future

Steve Jobs writes on the Apple site:

With the stunning global success of Apple’s iPod music player and iTunes online music store, some have called for Apple to “open” the digital rights management (DRM) system that Apple uses to protect its music against theft, so that music purchased from iTunes can be played on digital devices purchased from other companies, and protected music purchased from other online music stores can play on iPods. Let’s examine the current situation and how we got here, then look at three possible alternatives for the future.

...

and, having heard him I really wish he'd blog.

His thesis is that Apple keep Fairplay proprietary to protect their rights to sell music from the Big 4 who require DRM on online but (for the most part) not on CD sales. He calls on people to ask the Big 4 to remove the DRM restriction on online music.

What his argument fails to acknowledge is that the music companies are not persuing DRM to protect sales now but to create a strangehold in a CD-free world. At the point where they can stop CD production they hope to have everything safely DRM'd.

Expect Sony/BMG, Universal, Warner, and EMI to hold onto their DRM with a deathly grip.

07/02/2007 13:32 by Matt Mower | Permalink | comments:

I'm dropping the BBC

Just reading about the BBC's proposed move to lock customers into Windows for their on-demand service:

A report from the BBC Trust said that services will be unavailable to consumers who do not use Microsoft software or have an up-to-date version of Windows.

I'm pissed off enough about the BBC's continuing use of RealPlayer for their Radio services but this is the limit.

Despite not having TV reception (I still have the box for playing DVD's and using the GameCube) for a year I have continued to pay my license fee. I have asked the TV license authority whether I am okay to cancel it (I'm not sure how tricky their rules are). If necessary I will ditch the TV altogether and just use the computer for playing DVD's.

This is not any kind of public service broadcasting that I want to be a part of supporting.

07/02/2007 15:03 by Matt Mower | Permalink | comments:
More about: