Including external .rake files in your project's Rakefile -- keep your rake tasks organized!

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!

You've successfully subscribed to SmartLogic Blog
Great! Next, complete checkout for full access to SmartLogic Blog
Welcome back! You've successfully signed in.
Unable to sign you in. Please try again.
Success! Your account is fully activated, you now have access to all content.
Error! Stripe checkout failed.
Success! Your billing info is updated.
Error! Billing info update failed.