Open sshaw opened 4 years ago
Thanks for sharing these!
The gem could do with 'tightening up' some regexes and rules to keep such edge cases at bay. I guess the single characters can be dealt with relatively easily. With others, I don't know, tweaking the rules is rather hard. It may be that some of the rules could do with replacing .*
for .+
. Do you have time to contribute a PR?
Just curious how did you come about these? Are you actively using the gem in your project? Always keen to get feedback.
The intention was for the methods to accept a single word.
The methods could be extended to accept a variable number of nouns/verbs but I would be less inclined to support chunks of text with newline delimiters and such. So this would be my preferred approach:
Strings::Inflection.singularize("cars", "trucks", "bikes")
Do you have time to contribute a PR?
I'm not opposed to a good ol' fashioned PR. Feel free to remind me in 2 months if I don't do it!
⏳
Just curious how did you come about these? Are you actively using the gem in your project?
Trying, to use it in my project: class2
. Currently it uses ActiveSupport for these sorts of things and I'd like to add the word "lightweight" to class2's docs but this would be a programming crime considering it's using ActiveSupport!
The branch with your gems is here.
The intention was for the methods to accept a single word.
I don't want more than 1 I just noticed that your regex was matching on end of line so wasn't sure if it was a bug or a feature.
Using a lot of
.*
for regexes. Well at least in the case of"a"
this is certainly the problem.Also not sure if this is a feature or bug:
I think bug but saw you were using
\A
and$
instead of\A
and\z
so just asking.