# Only run the following code when this file is the main file being run
# instead of having been required or loaded by another file
if __FILE__==$0
# Find the parent directory of this file and add it to the front
# of the list of locations to look in when using require
$:.unshift File.expand_path("../../", __FILE__)
end
Note that this particular practice (adding to the LOAD_PATH directory) is not usually necessary with the advent of require_relative, and expand_path is a simpler way of finding the parent directory.