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

String Singularization #73

Merged
merged 3 commits into from
May 4, 2015
Merged

String Singularization #73

merged 3 commits into from
May 4, 2015

Conversation

AlfonsoUceda
Copy link
Contributor

Feature

Introduce singularization for strings.

How

It adds a new public API method: Utils::String#singularize, which returns a new singularized instance of the same type.

string = Lotus::Utils::String.new("flowers")
string.singularize       # => "flower"
string.singularize.class # => Lotus::Utils::String

The implementation is delegated to a new module: Lotus::Utils::Inflector. It exposes .singularize which works with Ruby's String.

Lotus::Utils::Inflector.singularize("flowers")       # => "flower"
Lotus::Utils::Inflector.singularize("flowers").class # => String

Sigunlaritazion is idempotent.

Lotus::Utils::Inflector.singularize(
  Lotus::Utils::Inflector.singularize("user")
) # => "user"

It respects the case:

Lotus::Utils::Inflector.singularize("Applications") # => "Application"

@jodosha jodosha self-assigned this May 4, 2015
@jodosha jodosha added the feature label May 4, 2015
@jodosha jodosha added this to the v0.4.1 milestone May 4, 2015
@jodosha
Copy link
Member

jodosha commented May 4, 2015

Me and @AlfonsoUceda had a private chat where we decided to mark as private API all these inflection features, as I'm not happy with the implementation, performance and results.

As now, they offer a great support to complete the feature that requested them: hanami/router#51

For this reason, we decide to :shipit: and review it later.

jodosha added a commit that referenced this pull request May 4, 2015
@jodosha jodosha merged commit 1645ed9 into hanami:master May 4, 2015
@runlevel5 runlevel5 changed the title Singularize [WIP] String Singularization May 15, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants