Replace deprecated Ruby methods

Replace `Hash#has_key?` and `File.exists?` with `Hash#key?` and `File.exist?`

Addresses #2658.