ember-inflector
ember-inflector copied to clipboard
support dasherized multi-word names?
When using ember-cli, it seems like it would be helpful to support the same inflection patterns for dasherized and undasherized names. Instead, I find myself doing the following:
Ember.Inflector.inflector.uncountable('phrase-tones')
Ember.Inflector.inflector.uncountable('phraseTones')
Of course, if I always wanted anything ending in tones to be uncountable, then I could just register the last word, but sometimes it's only class names that I want to be uncountable (i.e., in the case where each record represents a plural set of things).
Does the inflector know about word boundaries as presented in camelCase? This is a little tricky because of all-caps acronyms. Perhaps it could work as follows. If one registers the phrase-tones case then it also registers the phraseTones case, but not viceversa.
https://github.com/stefanpenner/ember-inflector/pull/41/files seems to already do this? Or maybe i need further clarification.
Hm...
It works on a new instance, but I get weird behavior from the instance on Ember.Inflector:

I suppose I'm doing something wrong...
@kbullaughey do you have 2 verison of ember-inflector ? ember-data does bring one with as-well...
Hm...seems I'm using the ember-data, whichever is packaged with ember-data 1.0.0-beta.14.1.
I added some tests to a branch in my forked copy. Here's a diff.
I get the following failures in testem:
ember-inflector.unit: multiword uncountable basic s singularization rule
✘ failed
expected blue_moons
actual blue_moon
✘ failed
expected blueMoons
actual blueMoon
✘ failed
expected BlueMoons
actual BlueMoon
Importantly, it only fails if there's a singularization rule (as is the case when using ember data). I am declaring inflector.uncountable('blue-moons'); and so inflector.singularize('blue-moons'); works, but not the other three multiword variants I test. In the last test I define rules for all three variants (dash, underscore, no spaces) and then all the multiword singularization rules work.
I haven't looked into the cause of the problem yet.