underscore.inflection
Advanced tools
Comparing version 1.0.0 to 1.0.1
var gulp = require('gulp'); | ||
var jscs = require('gulp-jscs'); | ||
var jscov = require('gulp-jscoverage'); | ||
var symlink = require('gulp-symlink'); | ||
var contribs = require('gulp-contribs'); | ||
gulp.task('jscs', function() { | ||
return gulp.src([ | ||
gulp.src([ | ||
'lib/*.js', | ||
@@ -17,1 +19,14 @@ 'test/*.js' | ||
}); | ||
gulp.task('contribs', function() { | ||
gulp.src('README.md') | ||
.pipe(contribs()) | ||
.pipe(gulp.dest('./')); | ||
}); | ||
gulp.task('docs', ['contribs']); | ||
gulp.task('install', function() { | ||
gulp.src('etc/hooks/*') | ||
.pipe(symlink('.git/hooks')); | ||
}); |
// Underscore.inflection.js | ||
// (c) 2011 Jeremy Ruppel | ||
// (c) 2014 Jeremy Ruppel | ||
// Underscore.inflection is freely distributable under the MIT license. | ||
@@ -17,2 +17,9 @@ // Portions of Underscore.inflection are inspired or borrowed from ActiveSupport | ||
/** | ||
* `gsub` is a method that is just slightly different than our | ||
* standard `String#replace`. The main differences are that it | ||
* matches globally every time, and if no substitution is made | ||
* it returns `null`. It accepts a string for `word` and | ||
* `replacement`, and `rule` can be either a string or a regex. | ||
*/ | ||
gsub: function(word, rule, replacement) { | ||
@@ -24,2 +31,6 @@ var pattern = new RegExp(rule.source || rule, 'gi'); | ||
/** | ||
* `plural` creates a new pluralization rule for the inflector. | ||
* `rule` can be either a string or a regex. | ||
*/ | ||
plural: function(rule, replacement) { | ||
@@ -29,2 +40,9 @@ plurals.unshift([rule, replacement]); | ||
/** | ||
* Pluralizes the string passed to it. It also can accept a | ||
* number as the second parameter. If a number is provided, | ||
* it will pluralize the word to match the number. Optionally, | ||
* you can pass `true` as a third parameter. If found, this | ||
* will include the count with the output. | ||
*/ | ||
pluralize: function(word, count, includeNumber) { | ||
@@ -57,2 +75,6 @@ var result; | ||
/** | ||
* `singular` creates a new singularization rule for the | ||
* inflector. `rule` can be either a string or a regex. | ||
*/ | ||
singular: function(rule, replacement) { | ||
@@ -62,2 +84,6 @@ singulars.unshift([rule, replacement]); | ||
/** | ||
* `singularize` returns the singular version of the plural | ||
* passed to it. | ||
*/ | ||
singularize: function(word) { | ||
@@ -80,2 +106,8 @@ if (_(uncountables).include(word)) { | ||
/** | ||
* `irregular` is a shortcut method to create both a | ||
* pluralization and singularization rule for the word at | ||
* the same time. You must supply both the singular form | ||
* and the plural form as explicit strings. | ||
*/ | ||
irregular: function(singular, plural) { | ||
@@ -86,2 +118,6 @@ this.plural('\\b' + singular + '\\b', plural); | ||
/** | ||
* `uncountable` creates a new uncountable rule for `word`. | ||
* Uncountable words do not get pluralized or singularized. | ||
*/ | ||
uncountable: function(word) { | ||
@@ -91,2 +127,5 @@ uncountables.unshift(word); | ||
/** | ||
* `ordinalize` adds an ordinal suffix to `number`. | ||
*/ | ||
ordinalize: function(number) { | ||
@@ -117,2 +156,6 @@ if (isNaN(number)) { | ||
/** | ||
* `titleize` capitalizes the first letter of each word in | ||
* the string `words`. It preserves the existing whitespace. | ||
*/ | ||
titleize: function(words) { | ||
@@ -128,2 +171,6 @@ if (typeof words !== 'string') { | ||
/** | ||
* Resets the inflector's rules to their initial state, | ||
* clearing out any custom rules that have been added. | ||
*/ | ||
resetInflections: function() { | ||
@@ -201,3 +248,2 @@ plurals = []; | ||
} | ||
}; | ||
@@ -204,0 +250,0 @@ |
{ | ||
"name": "underscore.inflection", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "ActiveSupport::Inflector, for underscore!", | ||
@@ -12,4 +12,5 @@ "main": "index.js", | ||
"coverage": "JSCOV=1 mocha -R mocha-lcov-reporter | coveralls", | ||
"jscov": "gulp jscov", | ||
"jscs": "gulp jscs", | ||
"jscov": "gulp jscov" | ||
"docs": "gulp docs" | ||
}, | ||
@@ -35,12 +36,14 @@ "repository": { | ||
"devDependencies": { | ||
"mocha": "~1.20.1", | ||
"underscore": "~1.6.0", | ||
"chai": "~1.9.1", | ||
"coveralls": "~2.11.1", | ||
"gulp": "~3.8.6", | ||
"gulp-contribs": "0.0.2", | ||
"gulp-jscoverage": "~0.1.0", | ||
"gulp-jscs": "~0.6.0", | ||
"coveralls": "~2.11.1", | ||
"gulp-symlink": "^1.1.0", | ||
"jscoverage": "~0.5.5", | ||
"mocha": "~1.20.1", | ||
"mocha-lcov-reporter": "0.0.1", | ||
"jscoverage": "~0.5.5", | ||
"gulp-jscoverage": "~0.1.0" | ||
"underscore": "~1.6.0" | ||
} | ||
} |
## underscore.inflection | ||
> [![NPM version][npm-badge]][npm] | ||
> [![Build Status][travis-badge]][travis-ci] | ||
@@ -156,4 +157,3 @@ > [![Coverage Status][coveralls-badge]][coveralls] | ||
Thanks to... | ||
------------ | ||
## Thanks to... | ||
@@ -172,2 +172,20 @@ The [Rails][rails] team for [ActiveSupport][activesupport] | ||
## Contributors | ||
``` | ||
30 Jeremy Ruppel | ||
7 Landon Schropp | ||
2 Johnathon Sanders | ||
2 Seggy Umboh | ||
1 Dayton Nolan | ||
1 Shane Riley | ||
1 trevor | ||
``` | ||
## License | ||
[MIT License][LICENSE] | ||
[npm]: http://badge.fury.io/js/underscore.inflection | ||
[npm-badge]: https://badge.fury.io/js/underscore.inflection.svg | ||
[travis-ci]: https://travis-ci.org/jeremyruppel/underscore.inflection | ||
@@ -181,1 +199,2 @@ [travis-badge]: https://travis-ci.org/jeremyruppel/underscore.inflection.svg?branch=master | ||
[documentcloud]: http://www.documentcloud.org/home | ||
[LICENSE]: https://github.com/jeremyruppel/underscore.inflection/blob/master/LICENSE |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
29788
23
528
198
11