class MiniPortile

def which(cmd)

which('ruby') #=> /usr/bin/ruby

Cross-platform way of finding an executable in the $PATH.

Thanks, Mislav!
From: http://stackoverflow.com/a/5471032/7672
def which(cmd)
  exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
  ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
    exts.each { |ext|
      exe = File.join(path, "#{cmd}#{ext}")
      return exe if File.executable? exe
    }
  end
  return nil
end