Skip to content

Instantly share code, notes, and snippets.

@universal
Created September 10, 2013 12:29
Show Gist options
  • Save universal/6508710 to your computer and use it in GitHub Desktop.
Save universal/6508710 to your computer and use it in GitHub Desktop.
## either this
response.each do |chunk|
[[/[\r\n]+/, ''], [/>\s+</, '><']].each do |reg, rep|
chunk.gsub! reg, rep
end
end
# or that
response = response.map do |chunk|
chunk.gsub(/[\r\n]+/, '').gsub(/>\s+/, '>').gsub(/>\s+</, '><').gsub(/; \s+/, '; ').gsub(/{ \s+/, '{ ').gsub(/<!--(.|\s)*?-->/, '')
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment