-
Notifications
You must be signed in to change notification settings - Fork 578
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow selection of an encoding on slurp/spew in Mojo::File #2089
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks quite useful to me. I assume spew is being added because spurt's API can't handle another argument as it would just use it as data.
@Grinnz Correct. Since spurt can take an array of content, we can't easily check the last argument. Discussion was that spurt would likely be done away with in time |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm in favor of this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Too bad we have both spew and spurt, but I like spew better, so I'm giving this change 👍
} | ||
|
||
sub spurt { | ||
my ($self, $content) = (shift, join '', @_); | ||
sub spew { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
This is great; thank you! |
Summary
Alter Mojo::File to:
$file->slurp('UTF-8');
etc.$file->spew('contents', 'UTF-8');
etc.Motivation
As we discussed on IRC, allowing these options not only makes it easier for users as well as bring things more inline with what is allowed in the Mojo.js framework.