Deprecate strip_heredoc?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Deprecate strip_heredoc?

Simon Perepelitsa
The new squiggly-heredoc syntax is available since Ruby 2.3, which does the same thing as "strip_heredoc" method. I was going to submit a documentation change to mention the new Ruby syntax, but now I'm doubting if there is any good use case for the method, except for backwards compatibility. Can it be deprecated?

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/rubyonrails-core.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-core/bddc1522-bc4c-439e-9774-79ddb0154f9b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Deprecate strip_heredoc?

George Claghorn-2
+1 for deprecating.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/rubyonrails-core.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-core/a7ed27ee2dcb46bd456278e6ca4cd6912088e576%40haystack-master-default-app-5677f8ff85-crff7.mail.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Deprecate strip_heredoc?

Xavier Noria
+1 too.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/rubyonrails-core.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-core/CAM%3DYcdg-5w386piouguCujy8NoKcr0CpHor9zwSrWiZHOuUv7w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Deprecate strip_heredoc?

Rafael Mendonça França
The squiggly-heredoc operator can't be applied to an already existing string. That is the only case were you still need strip_heredoc, so unless we add a way to strip heredocs from an already existent string object to Ruby we can't deprecated it.


On Sat, Jun 8, 2019 at 12:28 PM Xavier Noria <[hidden email]> wrote:
+1 too.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/rubyonrails-core.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-core/CAM%3DYcdg-5w386piouguCujy8NoKcr0CpHor9zwSrWiZHOuUv7w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/rubyonrails-core.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-core/CAC9YFze7jD8kc%3DhnCfTjsCa6pJHm2X5DbHZuYBD%3D_pB6ufnVdw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Deprecate strip_heredoc?

Matthew Draper


> The squiggly-heredoc operator can't be applied to an already existing string. That is the only case were you still need strip_heredoc, so unless we add a way to strip heredocs from an already existent string object to Ruby we can't deprecated it.

How about we rename it to something like `strip_indent`?

As you should no longer be using it on a heredoc, the current name isn’t a great fit.

And then we can deprecate the old name, with a suggestion to use <<~ if possible, or strip_indent if not.



--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/rubyonrails-core.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-core/5B924D0D-9CD2-41BD-8485-5A07ED807022%40trebex.net.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Deprecate strip_heredoc?

Godfrey Chan
+1 to what Matthew said

If we are switching the use case of the method to stripping indentation, I wonder if we should just call it `outdent`.

By default it could auto detect the indentation like it does now, but there were a couple of times I was processing strings with known indentation that I want to remove, but for some reason the auto detection wasn’t quite right. 

On Sun, Jun 9, 2019 at 2:03 AM Matthew Draper <[hidden email]> wrote:


> The squiggly-heredoc operator can't be applied to an already existing string. That is the only case were you still need strip_heredoc, so unless we add a way to strip heredocs from an already existent string object to Ruby we can't deprecated it.

How about we rename it to something like `strip_indent`?

As you should no longer be using it on a heredoc, the current name isn’t a great fit.

And then we can deprecate the old name, with a suggestion to use <<~ if possible, or strip_indent if not.



--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/rubyonrails-core.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-core/5B924D0D-9CD2-41BD-8485-5A07ED807022%40trebex.net.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/rubyonrails-core.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-core/CAC%3DHGusZfbvJfVdP38vhZwPz6Anz6gLUo8%2BGFNmzV1TKJViT6Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Deprecate strip_heredoc?

Godfrey Chan
Oops. Hit sent before completing the email.

Anyway, I was thinking it may be a good idea to take keyword arguments to precise control the amount of indentation/tab vs space, etc to override the auto-detection, in the rare cases where it is needed.

For example, when processing an indented markdown code block (triple backtick), it is a good idea to use the indentation level of the backtick instead of looking at the content. Some times there may be intentional indentation inside the code block that is meant to be part of the content (e.g. ASCII art and other kind of diagrams).

On Sun, Jun 9, 2019 at 7:22 PM Godfrey Chan <[hidden email]> wrote:
+1 to what Matthew said

If we are switching the use case of the method to stripping indentation, I wonder if we should just call it `outdent`.

By default it could auto detect the indentation like it does now, but there were a couple of times I was processing strings with known indentation that I want to remove, but for some reason the auto detection wasn’t quite right. 

On Sun, Jun 9, 2019 at 2:03 AM Matthew Draper <[hidden email]> wrote:


> The squiggly-heredoc operator can't be applied to an already existing string. That is the only case were you still need strip_heredoc, so unless we add a way to strip heredocs from an already existent string object to Ruby we can't deprecated it.

How about we rename it to something like `strip_indent`?

As you should no longer be using it on a heredoc, the current name isn’t a great fit.

And then we can deprecate the old name, with a suggestion to use <<~ if possible, or strip_indent if not.



--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/rubyonrails-core.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-core/5B924D0D-9CD2-41BD-8485-5A07ED807022%40trebex.net.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/rubyonrails-core.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-core/CAC%3DHGusZ%3D4oc5Vy6X%3DQHN82GT%3DB_rtqSXgn3R4RL_bhhNtexvw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.