Restore Ruby 1.8.7 support

Ruby 1.8.7 does not have the RUBY_ENGINE constant so check for it before
attempting to use it.