X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=bin%2Fwhatever-dl;h=9a6b8c3e23eabe2b02624fe5a38539b3de340d74;hb=c292aca3372339f92ea6fa8fa563ffed7f4fd19c;hp=a59e61b2d56a0c92ef5187315f1192456aa4e6fe;hpb=83e06f83d8274cb32a406739839d56e759664b09;p=dead%2Fwhatever-dl.git diff --git a/bin/whatever-dl b/bin/whatever-dl index a59e61b..9a6b8c3 100755 --- a/bin/whatever-dl +++ b/bin/whatever-dl @@ -1,4 +1,4 @@ -#!/usr/bin/ruby -w +#!/usr/bin/ruby -wKU # # whatever-dl, a script to download online (web-based) videos. # @@ -19,14 +19,31 @@ # 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' +# The Dir.glob that's coming up doesn't use the +# Ruby library path so we need to tell it where to +# look explicitly. +websites_pattern = File.dirname(executable) + '/../src/websites/*.rb' + # All of the website classes are located in one # directory, so we can 'require' them automatically. -Dir.glob('src/websites/*.rb').each do |r| +Dir.glob(websites_pattern).each do |r| require r end