Coder Social home page Coder Social logo

inflections's Introduction

Inflections

Inflections is a port of several of the ActiveSupport Inflector methods into Objective C. This was inspired by the wonderful inflection.js by Ryan Schuft (http://code.google.com/p/inflection-js/). The framework has all the support for camelization pluralization and some of the other nice features. It also depends on RegexKitLite for Regex support.

Usage

The simplest way to use the project is to add the NSString+Inflections.h and NSString+Inflections.m to your project. You will also need to have RegexKitLite in your project.

To install RegexKitLite check their site: http://regexkit.sourceforge.net/RegexKitLite/#AddingRegexKitLitetoyourProject

Supported Methods

- (NSString *)pluralize;

Returns the plural form of the word in the string.

- (NSString *)singularize;

The reverse of +pluralize+, returns the singular form of a word in a string.

- (NSString *)humanize;

Capitalizes the first word and turns underscores into spaces and strips a trailing "_id", if any. Like +titleize+, this is meant for creating pretty output.

- (NSString *)titleize;

Capitalizes all words that are not part of the nonTitlecasedWords.

- (NSString *)tableize;

Create the name of a table like Rails does for models to table names. This method uses the +pluralize+ method on the last word in the string.

- (NSString *)classify;

Create a class name from a plural table name like Rails does for table names to models.

- (NSString *)camelize;

Converts an underscored separated string into a CamelCasedString.

- (NSString *)camelizeWithLowerFirstLetter;

Converts an underscored separated string into a camelCasedString with the first letter lower case.

- (NSString *)underscore;

Makes an underscored, lowercase form from the expression in the string.

- (NSString *)dasherize;

Replaces underscores with dashes in the string.

- (NSString *)demodulize;

Removes the module part from the expression in the string.

- (NSString *)foreignKey;

Creates a foreign key name from a class name.

- (NSString *)foreignKeyWithoutIdUnderscore;

Creates a foreign key name from a class name without the underscore separating the id part.

- (NSString *)ordinalize;

Turns a number into an ordinal string used to denote the position in an ordered sequence such as 1st, 2nd, 3rd, 4th.

- (NSString *)capitalize;

Capitalizes the first letter and makes everything else lower case.

Issues

Currently some of the singularization tests are passing. The testing suite was ported over from Rails 3.0 and most of it's working. There are still a couple odd cases though.

Project Info

Copyright (c) 2010 Adam Elliot, released under the MIT license.

inflections's People

Contributors

deberle avatar adamelliot avatar

Stargazers

Angus H. avatar takishima avatar Thongchai Kolyutsakul avatar Sven C. Koehler avatar Schinckus Lionel avatar Ortwin Gentz, FutureTap avatar  avatar Glavin Wiechert avatar Jason Filipe avatar Brian Semiglia avatar Mike D avatar Eytan Biala avatar Cameron Ehrlich avatar Abraham Barrera avatar Alex Pretzlav avatar Pin Shih Wang avatar Ash Wu avatar  avatar Joseph Pirtle avatar  avatar Philip Dow avatar  avatar Brad Folkens avatar Tri Vuong avatar Neetesh Gupta avatar Paul C avatar Dmitry Seredinov avatar Gun.io Robot avatar Daniel W. Wall avatar Arnaud Coomans avatar Lars Anderson avatar  avatar Marcin avatar Cameron Spickert avatar Andrew Latimer avatar Zach Williams avatar Huiming Teo avatar Simon Fortelny avatar Karsten avatar Sergey Zenchenko avatar Brian Hammond avatar Elango avatar Nicholas Bruning avatar Ben Kreeger avatar Jean Regisser avatar  avatar Keith Pitt avatar Willi Wu avatar Adam McDonald avatar Fabien Franzen avatar Chris Moore avatar Max Riveiro avatar

Watchers

 avatar James Cloos avatar Dmitry Seredinov avatar  avatar

inflections's Issues

Please add semantic version tags

I’ve recently added Inflections to the CocoaPods package manager repo.

CocoaPods is a tool for managing dependencies for OSX and iOS Xcode projects and provides a central repository for iOS/OSX libraries. This makes adding libraries to a project and updating them extremely easy and it will help users to resolve dependencies of the libraries they use.

However, Inflections doesn't have any version tags. I’ve added the current HEAD as version 0.0.1, but a version tag will make dependency resolution much easier.

Semantic version tags (instead of plain commit hashes/revisions) allow for resolution of cross-dependencies.

In case you didn’t know this yet; you can tag the current HEAD as, for instance, version 1.0.0, like so:

$ git tag -a 1.0.0 -m "Tag release 1.0.0"
$ git push --tags

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.