Including external .rake files in your project’s Rakefile — keep your rake tasks organized!

May 26th, 2009 by

Perhaps you have a non-Rails project (let’s say it’s in ruby and maybe some other languages, too) and you use Rake tasks to automate some of the dirty work. So you’ve got a bunch of methods that you wish to keep neatly sorted into .rake files in some dir’s (probably a sub folder of lib like lib/tasks) and a single Rakefile in your project’s root directory. Including those external .rake files in your project’s Rakefile via require statements won’t work :

require 'lib/some_rake_file' # or require 'lib/some_rake_file.rake'

=> rake aborted!
no such file to load — /home/your_project/lib/some_rake_file

Rake assumes the ‘require’d files end in .rb, so it won’t find your .rake files. You need to import rake files:

import 'lib/some_rake_file'

This is fine for individual files, but I wanted to include all files that end in .rake in my tasks dir:

Dir.glob('tasks/*.rake').each { |r| import r }

…and there you go. While dead simple, this exemplifies an important distinction between require and import that I found to be poorly documented. Keep your rake tasks organized and remember that Rake isn’t just for rails apps!

SmartLogic Wants to Clean Up Twitter, Introduces ShouldIRT.com

May 5th, 2009 by

Are you tired of a world that lacks retweeting etiquette? You know who I’m talking about, that dude who’s always retweeting @THE_REAL_SHAQ or @guykawasaki. Or those guys with multiple twitter accounts who need to ensure that every last contact gets the message, several duplicate followers be damned!

Well, we’re sick of it…..and we’re not the only ones!
Read the rest of this entry »

Find the Unique Sessions for a Rails Application

May 4th, 2009 by

Today we’re going to look at how to find the number of unique sessions over a specific time frame for a rails application. We’ll be using the slow-actions gem.

Read the rest of this entry »