Skip to content

Instantly share code, notes, and snippets.

@Achillefs
Created October 18, 2010 11:29
Show Gist options
  • Save Achillefs/632065 to your computer and use it in GitHub Desktop.
Save Achillefs/632065 to your computer and use it in GitHub Desktop.
Add newlines to long ass XML files
Dir[File.join(%w[test fixtures files *.xml])].each do |file|
xml = File.read(file)
matches = xml.scan("\n")
if !matches or matches.size < 3
puts "#{file}: Not enough line brakes, adding them now..."
File.open(file,"w") do |f|
f.puts(xml.gsub(/(<[^\/]*>)/,"\n\\1"))
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment