From 683a3d565af34bd0fc63c659e8647707d466d7d9 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Sat, 15 Nov 2008 18:46:54 -0500 Subject: [PATCH] Fixed the relative path require issue. Now we should be able to symlink the main executable and run it from wherever. --- bin/whatever-dl | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/bin/whatever-dl b/bin/whatever-dl index a59e61b..79cbbee 100755 --- a/bin/whatever-dl +++ b/bin/whatever-dl @@ -19,6 +19,18 @@ # http://www.fsf.org/licensing/licenses/gpl.html # +# We need Pathname to get the real filesystem path +# of this script (and not, for example, the path of +# a symlink which points to it. +require 'pathname' + +# This bit of magic adds the parent directory (the +# project root) to the list of ruby load paths. +# Thus, our require statements will work regardless of +# how or from where the script was run. +executable = Pathname.new(__FILE__).realpath.to_s +$: << File.dirname(executable) + '/../' + # We require the UriUtilities class to handle # the download of the video URL. require 'src/uri_utilities' -- 2.43.2