Friday, October 19, 2012

Ruby Heredocs and whitespace


-    raise(Puppet::Error, "this is a really really long line that causes total terminal line wrap. That's something I typically try to avoid whenever I can!")
+    raise(Puppet::Error, <<-EOL.gsub(/\s+/, " ").strip)
+      this is a really really long line that thanks to a 
+      little bit of heredoc trickery can safely be multi
+      line, and the extra whitespace will be reduced down
+      to a single space. Pretty cool, eh!?
+    EOL

No comments:

Post a Comment