Converting KML/XML to Javascript
@Flambino has already explained the main problems in your code. I'd only add: 1) why do you use each_with_index if you don't actually use the indexes? 2) Ruby would have a terrible standard library if you needed 4 lines just to read the contents of a file: contents = File.read(path). 

That's how I'd write it:

require 'nokogiri'
require 'json'

kml = Nokogiri::XML(open("Stateborders.xml"))
coordinates_by_state = kml.css("Placemark").map do |placemark|
  state = placemark.at_css("name").text.strip
  coordinates = placemark.at_css("coordinates").text.strip.lines.map do |line|
    line.split(",").map { |coord| coord.to_f.round(6).to_s }
  end
  [state, coordinates]
end.to_h

jscode = "var stateBorders = #{coordinates_by_state.to_json};"
File.write("stateborders.js", jscode)