From: Michael Orlitzky Date: Sat, 15 Nov 2008 23:46:54 +0000 (-0500) Subject: Fixed the relative path require issue. Now we should be able to symlink the main... X-Git-Url: https://gitweb.michael.orlitzky.com/?p=dead%2Fwhatever-dl.git;a=commitdiff_plain;h=683a3d565af34bd0fc63c659e8647707d466d7d9 Fixed the relative path require issue. Now we should be able to symlink the main executable and run it from wherever. --- 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'