strings-case
strings-case copied to clipboard
Add ActiveSupport::Inflector Migration Guide
Hi,
A guide would be helpful:
camelize(s)=Strings:Case.pascalcase(s)camelize(s, :lower)=Strings::Case.camelcase(s)classify(s)=Strings::Case.pascalcase(Strings::Inflection.singularize(s))with caveats
etc...
Great idea! Please submit PR with whatever you can translate. 🙏
This would probably work best as a comparison table. However, strings-case is more focused and various bits will be done by other strings components which I stared documenting in the strings repository https://github.com/piotrmurach/strings.
I have some notes but there's not much overlap really. 4 methods maybe but caveats. Here are my notes, if you want me to reformat and open a PR I will but not sure it's worthwhile:
Not quite classify, does not account for "/".
No equiv for classify because of deletetion of "/" can only do for basename of namespace
Case.pascalcase("foo bar", :separator => "::")
Strings::Case.pascalcase(Strings::Inflection.singularize(name))
camelize = pascalcase
camelize(:lower) = camelcase
titlecase = humanize
Sorta, no inflections
Strings::Numeral.ordinalize(:short => true) = ordinalize
ordinal has no equiv.
I will add a comprehensive migration guide in the strings project itself when all the gems are updated. My goal is to achieve as much compatibility as possible to make it easy for people to transition.
For this gem, these should be equivalent:
| Strings::Case | ActiveSupport |
|---|---|
sentencecase |
humanize |
titlecase |
titleize |
snakecase |
underscore |
pascalcase |
camelize |
camelcase |
camelize(false) |
dashcase |
dasherize |
What remains to do is to ensure that by default the / and :: are handled the same way:
Strings::Case.snakecase("HTTP::StatusCode") # => "http/status_code"
Strings::Case.camelcase("http/status_code") #=> "HTTP::StatusCode"