Replace deprecated Ruby methods

Replace `Hash#has_key?` and `File.exists?` with `Hash#key?`
and `File.exist?`
Merge pull request #2664 from alfredxing/replace-deprecated-methods