Uploaded image for project: 'Puppet'
  1. Puppet
  2. PUP-6304

Add string formatting rules to String.new

    XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Ready for Engineering
    • Priority: Normal
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: PUP 5.y
    • Component/s: None
    • Labels:
      None
    • Template:
    • Acceptance Criteria:
      Hide

      That String($str, $ftm) with the listed new formats produce the intended result and that this is verified with unit tests.

      Show
      That String($str, $ftm) with the listed new formats produce the intended result and that this is verified with unit tests.
    • Sub-team:
    • Team:
      Froyo
    • Story Points:
      2
    • Release Notes Summary:
      Support for string formatting rules that controls handling of whitespace (various kind of trimming/stripping), and line endings have been added to String.new.

      Description

      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 native implementations of them). This would also support what is believed the most common use case for the stdlib squeeze function (compressing whitespace in the middle of strings).

        Attachments

          Activity

            People

            Assignee:
            Unassigned
            Reporter:
            henrik.lindberg Henrik Lindberg
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:

                Zendesk Support