+
+# Function to clean the temporary file.
+function clean
+{
+ if [ -f "$tmp" ]; then
+ rm "$tmp"
+ fi
+}
+
+# Function to test if the required version of Perl is installed.
+function test_perl
+{
+ echo -n "Testing Perl version ... "
+
+ if error=$( perl -e 'use 5.8.0;' 2>&1 ); then
+ echo_green "OK"
+ log "OK"
+ else
+ echo $error | sed "s/, stopped.*//"
+ echo_red "FAIL"
+ exit
+ fi
+}
+
+# Function to test if a given Perl module is installed.
+function test_perl_module
+{
+ local module=$1
+
+ echo -n "Testing required Perl module - \"$module\": "
+
+ if ! error=$( perl -M$module -e '' 2>&1 > /dev/null ); then
+ echo_red "FAIL"
+ echo " Try: perl -MCPAN -e 'install $module'"
+ exit
+ else
+ echo_green "OK"
+ log "OK"
+ fi
+}
+
+# Function to test if the required version of Ruby is installed.
+function test_ruby
+{
+ echo -n "Testing Ruby version ... "
+
+ if error=$( ruby -e 'raise "Ruby version 1.9 required--this is only #{RUBY_VERSION}" if RUBY_VERSION < "1.9"' 2>&1 ); then
+ echo_green "OK"
+ log "OK"
+ else
+ echo $error | sed "s/.*: //"
+ echo_red "FAIL"
+ exit
+ fi
+}
+
+# Function to test if a given Ruby gem is installed.
+function test_ruby_gem
+{
+ local gem=$1
+
+ echo -n "Testing required Ruby gem - \"$gem\": "
+
+ if error=$( gem list --local | grep $gem ); then
+ echo_green "OK"
+ log "OK"
+ else
+ echo_red "FAIL"
+ echo " Try: gem install $gem"
+ exit
+ fi
+}
+
+# Function to test is a given auxillary program is in $PATH.
+function test_aux_program
+{
+ local program=$1
+
+ echo -n "Testing auxiliary program - \"$program\": "
+
+ if command -v $program >/dev/null; then
+ echo_green "OK"
+ log "OK"
+ else
+ echo_yellow "WARNING"
+ log "WARNING"
+ fi
+}