Change Dir.exists? to File.directory?

For compatibility with Ruby 1.8.7, which doesn't support Dir.exists?
Hackily add support for Ruby 1.8.7

Ruby 1.8.7 encountered an error when using Grit, due to a conflict
between Jekyll and posix-spawn. Ruby 1.8.7 supports neither
String::force_encoding or IO::set_encoding.

Jekyll adds a fake String::force_encoding method for Ruby versions
below 1.9. Posix-spawn `read_and_write` method contains a conditional
block that uses both IO::set_encoding and Strings::force_encoding,
but checks only whether the user's version of Ruby supports the former.

Until posix-spawn is updated to check for IO::set_encoding, this fix
adds it as a fake method to support Ruby 1.8.7.
Merge branch '1.8.7fix'