Jira (PUP-6304) Add string formatting rules to String.new

11 views
Skip to first unread message

Henrik Lindberg (JIRA)

unread,
May 16, 2016, 11:38:03 AM5/16/16
to puppe...@googlegroups.com
Henrik Lindberg created an issue
 
Puppet / New Feature PUP-6304
Add string formatting rules to String.new
Issue Type: New Feature New Feature
Assignee: Unassigned
Created: 2016/05/16 8:37 AM
Fix Versions: PUP 4.6.0
Priority: Normal Normal
Reporter: Henrik Lindberg

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).

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v6.4.13#64028-sha1:b7939e9)
Atlassian logo

Henrik Lindberg (JIRA)

unread,
May 17, 2016, 8:47:03 PM5/17/16
to puppe...@googlegroups.com
Henrik Lindberg updated an issue
Change By: Henrik Lindberg
Sprint: Language  2106-06-01  Triage

Henrik Lindberg (JIRA)

unread,
Jul 5, 2016, 6:19:05 PM7/5/16
to puppe...@googlegroups.com
Henrik Lindberg updated an issue
Change By: Henrik Lindberg
Sprint: Language  Triage  2016-07-27

Steve Barlow (JIRA)

unread,
Jul 13, 2016, 4:23:09 PM7/13/16
to puppe...@googlegroups.com
Steve Barlow updated an issue
Change By: Steve Barlow
Sprint: Language 2016- 07 08 - 27 10 (3rd 1.6.0

Henrik Lindberg (JIRA)

unread,
Jul 18, 2016, 4:05:30 AM7/18/16
to puppe...@googlegroups.com
Henrik Lindberg updated an issue
Change By: Henrik Lindberg
Fix Version/s: PUP 4.6.0
Fix Version/s: PUP 4.7.0

Henrik Lindberg (JIRA)

unread,
Jul 19, 2016, 5:42:05 PM7/19/16
to puppe...@googlegroups.com
Henrik Lindberg updated an issue
Change By: Henrik Lindberg
Sprint: Language 2016-08-10 (3rd 1.6.0

Henrik Lindberg (JIRA)

unread,
Sep 7, 2016, 6:12:16 PM9/7/16
to puppe...@googlegroups.com
Henrik Lindberg updated an issue
Change By: Henrik Lindberg
Team: Puppet Developer Support
This message was sent by Atlassian JIRA (v6.4.14#64029-sha1:ae256fe)
Atlassian logo

Kenn Hussey (JIRA)

unread,
Oct 20, 2016, 10:06:03 AM10/20/16
to puppe...@googlegroups.com
Kenn Hussey updated an issue
Change By: Kenn Hussey
Fix Version/s: PUP 4.8.0
Fix Version/s: PUP 4.9.0

Kenn Hussey (JIRA)

unread,
Dec 27, 2016, 1:50:05 PM12/27/16
to puppe...@googlegroups.com
Kenn Hussey commented on New Feature PUP-6304
 
Re: Add string formatting rules to String.new

Henrik Lindberg this needs to be in the current sprint in order to make the cut for Puppet 4.9.0 (and puppet-agent 1.9.0). /cc Craig Gomes

Henrik Lindberg (JIRA)

unread,
Jan 2, 2017, 9:46:02 AM1/2/17
to puppe...@googlegroups.com
Henrik Lindberg updated an issue
 
Change By: Henrik Lindberg
Fix Version/s: PUP 4.9.0
Fix Version/s: PUP 5.y

Ethan Brown (JIRA)

unread,
May 16, 2017, 7:12:03 PM5/16/17
to puppe...@googlegroups.com
Ethan Brown updated an issue
Change By: Ethan Brown
Labels: triaged

Ethan Brown (JIRA)

unread,
May 16, 2017, 7:12:03 PM5/16/17
to puppe...@googlegroups.com
Ethan Brown updated an issue
Change By: Ethan Brown
Team: Puppet Developer Experience Agent

Henrik Lindberg (JIRA)

unread,
Nov 11, 2017, 5:55:02 AM11/11/17
to puppe...@googlegroups.com
Henrik Lindberg updated an issue
Change By: Henrik Lindberg
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:
{code}

# | 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
{code}

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++  native  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).
This message was sent by Atlassian JIRA (v7.0.2#70111-sha1:88534db)
Atlassian logo

David McTavish (Jira)

unread,
Dec 6, 2021, 11:26:02 AM12/6/21
to puppe...@googlegroups.com
David McTavish updated an issue
Change By: David McTavish
Labels: nice-to-have
This message was sent by Atlassian Jira (v8.13.2#813002-sha1:c495a97)
Atlassian logo

Josh Cooper (Jira)

unread,
Jan 12, 2022, 1:49:01 PM1/12/22
to puppe...@googlegroups.com
Josh Cooper commented on New Feature PUP-6304
 
Re: Add string formatting rules to String.new

This ticket is to add more format operations so that the stdlib functions are not needed.

The documentation should be updated in https://github.com/puppetlabs/puppet/blob/main/lib/puppet/functions/new.rb

And is publicly documented in "String to String" format operations under https://puppet.com/docs/puppet/7/function.html#conversion-to-string

The implementation should be updated in https://github.com/puppetlabs/puppet/blob/main/lib/puppet/pops/types/string_converter.rb

And tests should be updated in https://github.com/puppetlabs/puppet/blob/main/spec/unit/pops/types/string_converter_spec.rb

This message was sent by Atlassian Jira (v8.20.2#820002-sha1:829506d)
Atlassian logo

Josh Cooper (Jira)

unread,
Feb 8, 2022, 2:00:03 AM2/8/22
to puppe...@googlegroups.com

Josh Cooper (Jira)

unread,
Feb 17, 2022, 1:34:01 AM2/17/22
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Epic Link: PUP- 7263 6720

Josh Cooper (Jira)

unread,
Feb 23, 2022, 9:10:01 PM2/23/22
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Epic Link: PUP-6720
Reply all
Reply to author
Forward
0 new messages