Skip to content
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

support dasherized multi-word names? #61

Open
kbullaughey opened this issue Jan 28, 2015 · 5 comments
Open

support dasherized multi-word names? #61

kbullaughey opened this issue Jan 28, 2015 · 5 comments

Comments

@kbullaughey
Copy link

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.

@stefanpenner
Copy link
Member

https://github.com/stefanpenner/ember-inflector/pull/41/files seems to already do this? Or maybe i need further clarification.

@kbullaughey
Copy link
Author

Hm...

It works on a new instance, but I get weird behavior from the instance on Ember.Inflector:

blue_moons

I suppose I'm doing something wrong...

@stefanpenner
Copy link
Member

@kbullaughey do you have 2 verison of ember-inflector ? ember-data does bring one with as-well...

@kbullaughey
Copy link
Author

Hm...seems I'm using the ember-data, whichever is packaged with ember-data 1.0.0-beta.14.1.

@kbullaughey
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants