class Overcommit::Hook::PreCommit::XmlSyntax

Checks the syntax of any modified XML files.

Public Instance Methods

run() click to toggle source
# File lib/overcommit/hook/pre_commit/xml_syntax.rb, line 6
def run
  messages = []

  applicable_files.each do |file|
    begin
      REXML::Document.new(IO.read(file))
    rescue REXML::ParseException => e
      error = "Error parsing #{file}: #{e.message}"
      messages << Overcommit::Hook::Message.new(:error, file, nil, error)
    end
  end

  messages
end