|
String.new supports many formatting options. One group of features that deal with chomp/chop and line endings is missing.
Suggest that the following formats are added:
# | Format | String
|
# | ------ | ------
|
# | n | removes trailing \r\n or \n (i.e. 'chop'/'chomp')
|
# | l | removes left white space (lstrip)
|
# | L | same as left + all internal whitespace
|
# | r | removes right white space (rstrip)
|
# | R | same as r + all internal whitespace
|
# | T | trim left, right, and compress all internal whitespace to single char ' '
|
# | M | compress all internal whitespace to single char ' '
|
# | e | end line in unix style (all \r*\n sequences replaced with \n
|
# | E | end line in DOS style (all ([^\r])\n sequences replaced with \1\r\n
|
With these string formatting operations, the stdlib functions strip, lstrip, rstrip, chomp, chop can all be implemented in the puppet language (thus avoiding having C++ implementations of them, or calling slow ruby variants). This would also support what is believed the most common use case for the stdlib squeeze function (compressing whitespace in the middle of strings).
|