]> gitweb.michael.orlitzky.com - dead/whatever-dl.git/blobdiff - bin/whatever-dl
Fixed the KCODE is NONE warning.
[dead/whatever-dl.git] / bin / whatever-dl
index a59e61b2d56a0c92ef5187315f1192456aa4e6fe..9a6b8c3e23eabe2b02624fe5a38539b3de340d74 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/ruby -w
+#!/usr/bin/ruby -wKU
 #
 # whatever-dl, a script to download online (web-based) videos.
 #
 # 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