marcandre/backports — pull request #82 by TheConstructor (2013-12-30 11:29:22+00:00)
Title: (g)sub with Hash replacement

Since 1.9.2 Ruby supports a Hash as second argument to gsub and sub to give replacements based on the individual match.
I guess there is a better way than may implementation, but at least the gsub-part works pretty well.

Documentation is http://www.ruby-doc.org/core-1.9.2/String.html#method-i-sub and http://www.ruby-doc.org/core-1.9.2/String.html#method-i-gsub