Skip to content
Browse files

added client side inflect script

  • Loading branch information...
1 parent 2134e6d commit 65042f8688f4cfb3be81b04ab9fc8dd29338bae7 @MSNexploder committed
View
30 Cakefile
@@ -51,7 +51,10 @@ task "install", "Install inflect in your local repository", ->
build = (callback) ->
log "Compiling CoffeeScript to JavaScript ...", green
- exec "rm -rf lib && coffee -c -l -b -o lib src", callback
+ exec "rm -rf lib && coffee -c -l -b -o lib src", ->
+ log "Building client side script ...", green
+ data_plain = "window.inflect = require('./inflect');"
+ buildClient 'inflect', data_plain, callback
task "build", "Compile CoffeeScript to JavaScript", -> build onerror
task "watch", "Continously compile CoffeeScript to JavaScript", ->
@@ -59,6 +62,24 @@ task "watch", "Continously compile CoffeeScript to JavaScript", ->
cmd.stdout.on "data", (data) -> process.stdout.write green + data + reset
cmd.on "error", onerror
+buildClient = (name, data, callback) ->
+ browserify = require('browserify')
+ fileify = require('fileify')
+ jsp = require("uglify-js").parser
+ pro = require("uglify-js").uglify
+
+ b = browserify()
+ b.use fileify('files', __dirname, (file) -> file == path.join(__dirname, 'package.json'))
+ b.addEntry path.join(__dirname, 'src/index.coffee')
+ b.append data
+
+ fs.writeFile "client/#{name}.js", b.bundle(), ->
+ ast = jsp.parse b.bundle()
+ ast = pro.ast_mangle ast
+ ast = pro.ast_squeeze ast
+
+ fs.writeFile "client/#{name}.min.js", pro.gen_code(ast), callback
+
clean = (callback) ->
exec "rm -rf html lib docs", callback
@@ -69,7 +90,7 @@ task "clean", "Remove temporary files and such", -> clean onerror
runTests = (callback) ->
log "Running test suite ...", green
- exec "find spec -name '*-spec.coffee' -print | xargs vows", (err, stdout, stderr) ->
+ exec "vows spec/*-spec.coffee", (err, stdout, stderr) ->
process.stdout.write stdout
process.stderr.write stderr
callback err if callback
@@ -77,6 +98,11 @@ task "test", "Run all tests", ->
runTests (err) ->
process.stdout.on "drain", -> process.exit -1 if err
+task "test:client", "Run client tests", ->
+ build ->
+ log "Opening client tests in browser ...", green
+ exec "open spec/client/index.html"
+
## Documentation ##
View
926 client/inflect.js
@@ -0,0 +1,926 @@
+var require = function (file, cwd) {
+ var resolved = require.resolve(file, cwd || '/');
+ var mod = require.modules[resolved];
+ if (!mod) throw new Error(
+ 'Failed to resolve module ' + file + ', tried ' + resolved
+ );
+ var res = mod._cached ? mod._cached : mod();
+ return res;
+}
+var __require = require;
+
+require.paths = [];
+require.modules = {};
+require.extensions = [".js",".coffee"];
+
+require.resolve = (function () {
+ var core = {
+ 'assert': true,
+ 'events': true,
+ 'fs': true,
+ 'path': true,
+ 'vm': true
+ };
+
+ return function (x, cwd) {
+ if (!cwd) cwd = '/';
+
+ if (core[x]) return x;
+ var path = require.modules.path();
+ var y = cwd || '.';
+
+ if (x.match(/^(?:\.\.?\/|\/)/)) {
+ var m = loadAsFileSync(path.resolve(y, x))
+ || loadAsDirectorySync(path.resolve(y, x));
+ if (m) return m;
+ }
+
+ var n = loadNodeModulesSync(x, y);
+ if (n) return n;
+
+ throw new Error("Cannot find module '" + x + "'");
+
+ function loadAsFileSync (x) {
+ if (require.modules[x]) {
+ return x;
+ }
+
+ for (var i = 0; i < require.extensions.length; i++) {
+ var ext = require.extensions[i];
+ if (require.modules[x + ext]) return x + ext;
+ }
+ }
+
+ function loadAsDirectorySync (x) {
+ x = x.replace(/\/+$/, '');
+ var pkgfile = x + '/package.json';
+ if (require.modules[pkgfile]) {
+ var pkg = require.modules[pkgfile]();
+ var b = pkg.browserify;
+ if (typeof b === 'object' && b.main) {
+ var m = loadAsFileSync(path.resolve(x, b.main));
+ if (m) return m;
+ }
+ else if (typeof b === 'string') {
+ var m = loadAsFileSync(path.resolve(x, b));
+ if (m) return m;
+ }
+ else if (pkg.main) {
+ var m = loadAsFileSync(path.resolve(x, pkg.main));
+ if (m) return m;
+ }
+ }
+
+ return loadAsFileSync(x + '/index');
+ }
+
+ function loadNodeModulesSync (x, start) {
+ var dirs = nodeModulesPathsSync(start);
+ for (var i = 0; i < dirs.length; i++) {
+ var dir = dirs[i];
+ var m = loadAsFileSync(dir + '/' + x);
+ if (m) return m;
+ var n = loadAsDirectorySync(dir + '/' + x);
+ if (n) return n;
+ }
+
+ var m = loadAsFileSync(x);
+ if (m) return m;
+ }
+
+ function nodeModulesPathsSync (start) {
+ var parts;
+ if (start === '/') parts = [ '' ];
+ else parts = path.normalize(start).split('/');
+
+ var dirs = [];
+ for (var i = parts.length - 1; i >= 0; i--) {
+ if (parts[i] === 'node_modules') continue;
+ var dir = parts.slice(0, i + 1).join('/') + '/node_modules';
+ dirs.push(dir);
+ }
+
+ return dirs;
+ }
+ };
+})();
+
+require.alias = function (from, to) {
+ var path = require.modules.path();
+ var res = null;
+ try {
+ res = require.resolve(from + '/package.json', '/');
+ }
+ catch (err) {
+ res = require.resolve(from, '/');
+ }
+ var basedir = path.dirname(res);
+
+ var keys = Object_keys(require.modules);
+
+ for (var i = 0; i < keys.length; i++) {
+ var key = keys[i];
+ if (key.slice(0, basedir.length + 1) === basedir + '/') {
+ var f = key.slice(basedir.length);
+ require.modules[to + f] = require.modules[basedir + f];
+ }
+ else if (key === basedir) {
+ require.modules[to] = require.modules[basedir];
+ }
+ }
+};
+
+var Object_keys = Object.keys || function (obj) {
+ var res = [];
+ for (var key in obj) res.push(key)
+ return res;
+};
+
+if (typeof process === 'undefined') process = {};
+
+if (!process.nextTick) process.nextTick = function (fn) {
+ setTimeout(fn, 0);
+};
+
+if (!process.title) process.title = 'browser';
+
+if (!process.binding) process.binding = function (name) {
+ if (name === 'evals') return require('vm')
+ else throw new Error('No such module')
+};
+
+if (!process.cwd) process.cwd = function () { return '.' };
+
+require.modules["path"] = function () {
+ var module = { exports : {} };
+ var exports = module.exports;
+ var __dirname = ".";
+ var __filename = "path";
+
+ var require = function (file) {
+ return __require(file, ".");
+ };
+
+ require.resolve = function (file) {
+ return __require.resolve(name, ".");
+ };
+
+ require.modules = __require.modules;
+ __require.modules["path"]._cached = module.exports;
+
+ (function () {
+ function filter (xs, fn) {
+ var res = [];
+ for (var i = 0; i < xs.length; i++) {
+ if (fn(xs[i], i, xs)) res.push(xs[i]);
+ }
+ return res;
+}
+
+// resolves . and .. elements in a path array with directory names there
+// must be no slashes, empty elements, or device names (c:\) in the array
+// (so also no leading and trailing slashes - it does not distinguish
+// relative and absolute paths)
+function normalizeArray(parts, allowAboveRoot) {
+ // if the path tries to go above the root, `up` ends up > 0
+ var up = 0;
+ for (var i = parts.length; i >= 0; i--) {
+ var last = parts[i];
+ if (last == '.') {
+ parts.splice(i, 1);
+ } else if (last === '..') {
+ parts.splice(i, 1);
+ up++;
+ } else if (up) {
+ parts.splice(i, 1);
+ up--;
+ }
+ }
+
+ // if the path is allowed to go above the root, restore leading ..s
+ if (allowAboveRoot) {
+ for (; up--; up) {
+ parts.unshift('..');
+ }
+ }
+
+ return parts;
+}
+
+// Regex to split a filename into [*, dir, basename, ext]
+// posix version
+var splitPathRe = /^(.+\/(?!$)|\/)?((?:.+?)?(\.[^.]*)?)$/;
+
+// path.resolve([from ...], to)
+// posix version
+exports.resolve = function() {
+var resolvedPath = '',
+ resolvedAbsolute = false;
+
+for (var i = arguments.length; i >= -1 && !resolvedAbsolute; i--) {
+ var path = (i >= 0)
+ ? arguments[i]
+ : process.cwd();
+
+ // Skip empty and invalid entries
+ if (typeof path !== 'string' || !path) {
+ continue;
+ }
+
+ resolvedPath = path + '/' + resolvedPath;
+ resolvedAbsolute = path.charAt(0) === '/';
+}
+
+// At this point the path should be resolved to a full absolute path, but
+// handle relative paths to be safe (might happen when process.cwd() fails)
+
+// Normalize the path
+resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {
+ return !!p;
+ }), !resolvedAbsolute).join('/');
+
+ return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
+};
+
+// path.normalize(path)
+// posix version
+exports.normalize = function(path) {
+var isAbsolute = path.charAt(0) === '/',
+ trailingSlash = path.slice(-1) === '/';
+
+// Normalize the path
+path = normalizeArray(filter(path.split('/'), function(p) {
+ return !!p;
+ }), !isAbsolute).join('/');
+
+ if (!path && !isAbsolute) {
+ path = '.';
+ }
+ if (path && trailingSlash) {
+ path += '/';
+ }
+
+ return (isAbsolute ? '/' : '') + path;
+};
+
+
+// posix version
+exports.join = function() {
+ var paths = Array.prototype.slice.call(arguments, 0);
+ return exports.normalize(filter(paths, function(p, index) {
+ return p && typeof p === 'string';
+ }).join('/'));
+};
+
+
+exports.dirname = function(path) {
+ var dir = splitPathRe.exec(path)[1] || '';
+ var isWindows = false;
+ if (!dir) {
+ // No dirname
+ return '.';
+ } else if (dir.length === 1 ||
+ (isWindows && dir.length <= 3 && dir.charAt(1) === ':')) {
+ // It is just a slash or a drive letter with a slash
+ return dir;
+ } else {
+ // It is a full dirname, strip trailing slash
+ return dir.substring(0, dir.length - 1);
+ }
+};
+
+
+exports.basename = function(path, ext) {
+ var f = splitPathRe.exec(path)[2] || '';
+ // TODO: make this comparison case-insensitive on windows?
+ if (ext && f.substr(-1 * ext.length) === ext) {
+ f = f.substr(0, f.length - ext.length);
+ }
+ return f;
+};
+
+
+exports.extname = function(path) {
+ return splitPathRe.exec(path)[3] || '';
+};
+;
+ }).call(module.exports);
+
+ __require.modules["path"]._cached = module.exports;
+ return module.exports;
+};
+
+require.modules["/node_modules/files"] = function () {
+ var module = { exports : {} };
+ var exports = module.exports;
+ var __dirname = "/node_modules";
+ var __filename = "/node_modules/files";
+
+ var require = function (file) {
+ return __require(file, "/node_modules");
+ };
+
+ require.resolve = function (file) {
+ return __require.resolve(name, "/node_modules");
+ };
+
+ require.modules = __require.modules;
+ __require.modules["/node_modules/files"]._cached = module.exports;
+
+ (function () {
+ module.exports = {"package.json":"{\n \"name\": \"inflect\",\n \"description\": \"A port of the Rails / ActiveSupport inflector to JavaScript.\",\n \"keywords\": [\"inflect\", \"activerecord\", \"rails\", \"activesupport\", \"string\"],\n \"version\": \"0.1.4\",\n \"author\": \"Stefan Huber <MSNexploder@gmail.com>\",\n \"homepage\": \"http://msnexploder.github.com/inflect/\",\n \"main\": \"lib/inflect\",\n \"files\": [\n \"Cakefile\",\n \"CHANGELOG.md\",\n \"doc\",\n \"lib\",\n \"LICENSE\",\n \"README.md\",\n \"spec\",\n \"src\"\n ],\n \"scripts\": {\n \"test\": \"cake test\"\n },\n \"directories\": {\n \"doc\":\"./doc\",\n \"lib\":\"./lib\"\n },\n \"engines\": {\n \"node\": \">= 0.4.x <= 0.6.0\"\n },\n \"devDependencies\": {\n \"coffee-script\": \">= 1.1.2 < 2.0.0\",\n \"docco\": \">= 0.3.0 < 0.4.0\",\n \"vows\": \">= 0.5.13 < 0.6.0\",\n \"browserify\": \">= 1.8.1 < 1.9.0\",\n \"fileify\": \">= 0.3.1 < 0.4.0\",\n \"uglify-js\": \">= 1.1.1 < 1.2.0\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/MSNexploder/inflect.git\"\n },\n \"bugs\": { \"url\": \"https://github.com/MSNexploder/inflect/issues\" },\n \"licenses\": [\n { \"type\": \"MIT\",\n \"url\": \"https://github.com/MSNexploder/inflect/raw/master/LICENSE\"\n }\n ]\n}"}
+;
+ }).call(module.exports);
+
+ __require.modules["/node_modules/files"]._cached = module.exports;
+ return module.exports;
+};
+
+require.modules["/inflect/index.coffee"] = function () {
+ var module = { exports : {} };
+ var exports = module.exports;
+ var __dirname = "/inflect";
+ var __filename = "/inflect/index.coffee";
+
+ var require = function (file) {
+ return __require(file, "/inflect");
+ };
+
+ require.resolve = function (file) {
+ return __require.resolve(name, "/inflect");
+ };
+
+ require.modules = __require.modules;
+ __require.modules["/inflect/index.coffee"]._cached = module.exports;
+
+ (function () {
+ (function() {
+ var Inflections, inflections, methods, number_extensions, string_extensions, version;
+ version = require('./version');
+ exports.package = version.package;
+ exports.version = version.version;
+ Inflections = require('./inflections').Inflections;
+ inflections = function(callback) {
+ if (callback != null) {
+ callback.call(this, Inflections.instance());
+ }
+ return Inflections.instance();
+ };
+ exports.Inflections = Inflections;
+ exports.inflections = inflections;
+ methods = require('./methods');
+ exports.camelize = methods.camelize;
+ exports.underscore = methods.underscore;
+ exports.dasherize = methods.dasherize;
+ exports.titleize = methods.titleize;
+ exports.capitalize = methods.capitalize;
+ exports.pluralize = methods.pluralize;
+ exports.singularize = methods.singularize;
+ exports.humanize = methods.humanize;
+ exports.ordinalize = methods.ordinalize;
+ exports.parameterize = methods.parameterize;
+ string_extensions = require('./string_extensions');
+ number_extensions = require('./number_extensions');
+ exports.enableStringExtensions = string_extensions.enableStringExtensions;
+ exports.enableNumberExtensions = number_extensions.enableNumberExtensions;
+ exports.enableExtensions = function() {
+ string_extensions.enableStringExtensions();
+ return number_extensions.enableNumberExtensions();
+ };
+ require('./default_inflections');
+}).call(this);
+;
+ }).call(module.exports);
+
+ __require.modules["/inflect/index.coffee"]._cached = module.exports;
+ return module.exports;
+};
+
+require.modules["/inflect/version.coffee"] = function () {
+ var module = { exports : {} };
+ var exports = module.exports;
+ var __dirname = "/inflect";
+ var __filename = "/inflect/version.coffee";
+
+ var require = function (file) {
+ return __require(file, "/inflect");
+ };
+
+ require.resolve = function (file) {
+ return __require.resolve(name, "/inflect");
+ };
+
+ require.modules = __require.modules;
+ __require.modules["/inflect/version.coffee"]._cached = module.exports;
+
+ (function () {
+ (function() {
+ var data, path;
+ path = require('path');
+ if (process.title === 'browser') {
+ data = require('files')['package.json'];
+ } else {
+ data = require('fs').readFileSync(path.join(__dirname, '/../../package.json'));
+ }
+ exports.package = JSON.parse(data);
+ exports.version = exports.package.version;
+}).call(this);
+;
+ }).call(module.exports);
+
+ __require.modules["/inflect/version.coffee"]._cached = module.exports;
+ return module.exports;
+};
+
+require.modules["/inflect/inflections.coffee"] = function () {
+ var module = { exports : {} };
+ var exports = module.exports;
+ var __dirname = "/inflect";
+ var __filename = "/inflect/inflections.coffee";
+
+ var require = function (file) {
+ return __require(file, "/inflect");
+ };
+
+ require.resolve = function (file) {
+ return __require.resolve(name, "/inflect");
+ };
+
+ require.modules = __require.modules;
+ __require.modules["/inflect/inflections.coffee"]._cached = module.exports;
+
+ (function () {
+ (function() {
+ var Inflections;
+ var __slice = Array.prototype.slice;
+ Inflections = (function() {
+ Inflections.instance = function() {
+ return this.__instance__ || (this.__instance__ = new this);
+ };
+ function Inflections() {
+ this.plurals = [];
+ this.singulars = [];
+ this.uncountables = [];
+ this.humans = [];
+ }
+ Inflections.prototype.plural = function(rule, replacement) {
+ var index;
+ if (typeof rule === 'string' && (index = this.uncountables.indexOf(rule)) !== -1) {
+ this.uncountables.splice(index, 1);
+ }
+ if ((index = this.uncountables.indexOf(replacement)) !== -1) {
+ this.uncountables.splice(index, 1);
+ }
+ return this.plurals.unshift([rule, replacement]);
+ };
+ Inflections.prototype.singular = function(rule, replacement) {
+ var index;
+ if (typeof rule === 'string' && (index = this.uncountables.indexOf(rule)) !== -1) {
+ this.uncountables.splice(index, 1);
+ }
+ if ((index = this.uncountables.indexOf(replacement)) !== -1) {
+ this.uncountables.splice(index, 1);
+ }
+ return this.singulars.unshift([rule, replacement]);
+ };
+ Inflections.prototype.irregular = function(singular, plural) {
+ var index;
+ if ((index = this.uncountables.indexOf(singular)) !== -1) {
+ this.uncountables.splice(index, 1);
+ }
+ if ((index = this.uncountables.indexOf(plural)) !== -1) {
+ this.uncountables.splice(index, 1);
+ }
+ if (singular[0].toUpperCase() === plural[0].toUpperCase()) {
+ this.plural(new RegExp("(" + singular[0] + ")" + singular.slice(1) + "$", "i"), '$1' + plural.slice(1));
+ this.plural(new RegExp("(" + plural[0] + ")" + plural.slice(1) + "$", "i"), '$1' + plural.slice(1));
+ return this.singular(new RegExp("(" + plural[0] + ")" + plural.slice(1) + "$", "i"), '$1' + singular.slice(1));
+ } else {
+ this.plural(new RegExp("" + (singular[0].toUpperCase()) + singular.slice(1) + "$"), plural[0].toUpperCase() + plural.slice(1));
+ this.plural(new RegExp("" + (singular[0].toLowerCase()) + singular.slice(1) + "$"), plural[0].toLowerCase() + plural.slice(1));
+ this.plural(new RegExp("" + (plural[0].toUpperCase()) + plural.slice(1) + "$"), plural[0].toUpperCase() + plural.slice(1));
+ this.plural(new RegExp("" + (plural[0].toLowerCase()) + plural.slice(1) + "$"), plural[0].toLowerCase() + plural.slice(1));
+ this.singular(new RegExp("" + (plural[0].toUpperCase()) + plural.slice(1) + "$"), singular[0].toUpperCase() + singular.slice(1));
+ return this.singular(new RegExp("" + (plural[0].toLowerCase()) + plural.slice(1) + "$"), singular[0].toLowerCase() + singular.slice(1));
+ }
+ };
+ Inflections.prototype.uncountable = function() {
+ var words;
+ words = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
+ return this.uncountables = this.uncountables.concat(words);
+ };
+ Inflections.prototype.human = function(rule, replacement) {
+ return this.humans.unshift([rule, replacement]);
+ };
+ Inflections.prototype.clear = function(scope) {
+ if (scope == null) {
+ scope = 'all';
+ }
+ if (scope === 'all') {
+ this.plurals = [];
+ this.singulars = [];
+ this.uncountables = [];
+ return this.humans = [];
+ } else {
+ return this[scope] = [];
+ }
+ };
+ return Inflections;
+ })();
+ exports.Inflections = Inflections;
+}).call(this);
+;
+ }).call(module.exports);
+
+ __require.modules["/inflect/inflections.coffee"]._cached = module.exports;
+ return module.exports;
+};
+
+require.modules["/inflect/methods.coffee"] = function () {
+ var module = { exports : {} };
+ var exports = module.exports;
+ var __dirname = "/inflect";
+ var __filename = "/inflect/methods.coffee";
+
+ var require = function (file) {
+ return __require(file, "/inflect");
+ };
+
+ require.resolve = function (file) {
+ return __require.resolve(name, "/inflect");
+ };
+
+ require.modules = __require.modules;
+ __require.modules["/inflect/methods.coffee"]._cached = module.exports;
+
+ (function () {
+ (function() {
+ var camelize, capitalize, dasherize, humanize, inflections, ordinalize, parameterize, pluralize, singularize, titleize, underscore;
+ inflections = require('../inflect').inflections;
+ camelize = function(lower_case_and_underscored_word, first_letter_in_uppercase) {
+ var rest;
+ if (first_letter_in_uppercase == null) {
+ first_letter_in_uppercase = true;
+ }
+ rest = lower_case_and_underscored_word.replace(/_./g, function(val) {
+ return val.slice(1).toUpperCase();
+ });
+ if (first_letter_in_uppercase) {
+ return lower_case_and_underscored_word[0].toUpperCase() + rest.slice(1);
+ } else {
+ return lower_case_and_underscored_word[0].toLowerCase() + rest.slice(1);
+ }
+ };
+ underscore = function(camel_cased_word) {
+ var word;
+ word = camel_cased_word.toString();
+ word = word.replace(/([A-Z]+)([A-Z][a-z])/g, '$1_$2');
+ word = word.replace(/([a-z\d])([A-Z])/g, '$1_$2');
+ word = word.replace(/-/g, '_');
+ word = word.toLowerCase();
+ return word;
+ };
+ dasherize = function(underscored_word) {
+ return underscored_word.replace(/_/g, '-');
+ };
+ titleize = function(word) {
+ return humanize(underscore(word)).replace(/\b('?[a-z])/g, function(val) {
+ return capitalize(val);
+ });
+ };
+ capitalize = function(word) {
+ return (word[0] || '').toUpperCase() + (word.slice(1) || '').toLowerCase();
+ };
+ pluralize = function(word) {
+ var plural, replacement, result, rule, _i, _len, _ref;
+ result = word.toString();
+ if (word.length === 0 || inflections().uncountables.indexOf(result.toLowerCase()) !== -1) {
+ return result;
+ } else {
+ _ref = inflections().plurals;
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ plural = _ref[_i];
+ rule = plural[0];
+ replacement = plural[1];
+ if (result.search(rule) !== -1) {
+ result = result.replace(rule, replacement);
+ break;
+ }
+ }
+ return result;
+ }
+ };
+ singularize = function(word) {
+ var inflection, replacement, result, rule, singular, uncountable, _i, _j, _len, _len2, _ref, _ref2;
+ result = word.toString();
+ uncountable = false;
+ _ref = inflections().uncountables;
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ inflection = _ref[_i];
+ if (result.search(new RegExp("\\b" + inflection + "$", 'i')) !== -1) {
+ uncountable = true;
+ break;
+ }
+ }
+ if (word.length === 0 || uncountable) {
+ return result;
+ } else {
+ _ref2 = inflections().singulars;
+ for (_j = 0, _len2 = _ref2.length; _j < _len2; _j++) {
+ singular = _ref2[_j];
+ rule = singular[0];
+ replacement = singular[1];
+ if (result.search(rule) !== -1) {
+ result = result.replace(rule, replacement);
+ break;
+ }
+ }
+ return result;
+ }
+ };
+ humanize = function(lower_case_and_underscored_word) {
+ var human, replacement, result, rule, _i, _len, _ref;
+ result = lower_case_and_underscored_word.toString();
+ _ref = inflections().humans;
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ human = _ref[_i];
+ rule = human[0];
+ replacement = human[1];
+ if (result.search(rule) !== -1) {
+ result = result.replace(rule, replacement);
+ break;
+ }
+ }
+ return capitalize(result.replace(/_id$/, '').replace(/_/g, ' '));
+ };
+ ordinalize = function(number) {
+ var number_int;
+ number_int = parseInt(number, 10);
+ if ([11, 12, 13].indexOf(number_int % 100) !== -1) {
+ return "" + number + "th";
+ } else {
+ switch (number_int % 10) {
+ case 1:
+ return "" + number + "st";
+ break;
+ case 2:
+ return "" + number + "nd";
+ break;
+ case 3:
+ return "" + number + "rd";
+ break;
+ default:
+ return "" + number + "th";
+ }
+ }
+ };
+ parameterize = function(string, sep) {
+ var parameterized_string;
+ if (sep == null) {
+ sep = '-';
+ }
+ parameterized_string = string.toString();
+ parameterized_string = parameterized_string.replace(/[^a-z0-9\-_]+/gi, sep);
+ if (sep != null) {
+ parameterized_string = parameterized_string.replace(new RegExp("" + sep + "{2,}", 'g'), sep);
+ parameterized_string = parameterized_string.replace(new RegExp("^" + sep + "|" + sep + "$", 'gi'), '');
+ }
+ return parameterized_string.toLowerCase();
+ };
+ exports.camelize = camelize;
+ exports.underscore = underscore;
+ exports.dasherize = dasherize;
+ exports.titleize = titleize;
+ exports.capitalize = capitalize;
+ exports.pluralize = pluralize;
+ exports.singularize = singularize;
+ exports.humanize = humanize;
+ exports.ordinalize = ordinalize;
+ exports.parameterize = parameterize;
+}).call(this);
+;
+ }).call(module.exports);
+
+ __require.modules["/inflect/methods.coffee"]._cached = module.exports;
+ return module.exports;
+};
+
+require.modules["/inflect/string_extensions.coffee"] = function () {
+ var module = { exports : {} };
+ var exports = module.exports;
+ var __dirname = "/inflect";
+ var __filename = "/inflect/string_extensions.coffee";
+
+ var require = function (file) {
+ return __require(file, "/inflect");
+ };
+
+ require.resolve = function (file) {
+ return __require.resolve(name, "/inflect");
+ };
+
+ require.modules = __require.modules;
+ __require.modules["/inflect/string_extensions.coffee"]._cached = module.exports;
+
+ (function () {
+ (function() {
+ var enableStringExtensions, inflect;
+ inflect = require('../inflect');
+ enableStringExtensions = function() {
+ String.prototype.pluralize = function() {
+ return inflect.pluralize(this);
+ };
+ String.prototype.singularize = function() {
+ return inflect.singularize(this);
+ };
+ String.prototype.camelize = function(first_letter_in_uppercase) {
+ if (first_letter_in_uppercase == null) {
+ first_letter_in_uppercase = true;
+ }
+ return inflect.camelize(this, first_letter_in_uppercase);
+ };
+ String.prototype.capitalize = function() {
+ return inflect.capitalize(this);
+ };
+ String.prototype.titleize = function() {
+ return inflect.titleize(this);
+ };
+ String.prototype.underscore = function() {
+ return inflect.underscore(this);
+ };
+ String.prototype.dasherize = function() {
+ return inflect.dasherize(this);
+ };
+ String.prototype.parameterize = function(sep) {
+ if (sep == null) {
+ sep = '-';
+ }
+ return inflect.parameterize(this, sep);
+ };
+ return String.prototype.humanize = function() {
+ return inflect.humanize(this);
+ };
+ };
+ exports.enableStringExtensions = enableStringExtensions;
+}).call(this);
+;
+ }).call(module.exports);
+
+ __require.modules["/inflect/string_extensions.coffee"]._cached = module.exports;
+ return module.exports;
+};
+
+require.modules["/inflect/number_extensions.coffee"] = function () {
+ var module = { exports : {} };
+ var exports = module.exports;
+ var __dirname = "/inflect";
+ var __filename = "/inflect/number_extensions.coffee";
+
+ var require = function (file) {
+ return __require(file, "/inflect");
+ };
+
+ require.resolve = function (file) {
+ return __require.resolve(name, "/inflect");
+ };
+
+ require.modules = __require.modules;
+ __require.modules["/inflect/number_extensions.coffee"]._cached = module.exports;
+
+ (function () {
+ (function() {
+ var enableNumberExtensions, inflect;
+ inflect = require('../inflect');
+ enableNumberExtensions = function() {
+ return Number.prototype.ordinalize = function() {
+ return inflect.ordinalize(this);
+ };
+ };
+ exports.enableNumberExtensions = enableNumberExtensions;
+}).call(this);
+;
+ }).call(module.exports);
+
+ __require.modules["/inflect/number_extensions.coffee"]._cached = module.exports;
+ return module.exports;
+};
+
+require.modules["/inflect/default_inflections.coffee"] = function () {
+ var module = { exports : {} };
+ var exports = module.exports;
+ var __dirname = "/inflect";
+ var __filename = "/inflect/default_inflections.coffee";
+
+ var require = function (file) {
+ return __require(file, "/inflect");
+ };
+
+ require.resolve = function (file) {
+ return __require.resolve(name, "/inflect");
+ };
+
+ require.modules = __require.modules;
+ __require.modules["/inflect/default_inflections.coffee"]._cached = module.exports;
+
+ (function () {
+ (function() {
+ var inflect;
+ inflect = require('../inflect');
+ inflect.inflections(function(inflect) {
+ inflect.plural(/$/, 's');
+ inflect.plural(/s$/i, 's');
+ inflect.plural(/(ax|test)is$/i, '$1es');
+ inflect.plural(/(octop|vir)us$/i, '$1i');
+ inflect.plural(/(octop|vir)i$/i, '$1i');
+ inflect.plural(/(alias|status)$/i, '$1es');
+ inflect.plural(/(bu)s$/i, '$1ses');
+ inflect.plural(/(buffal|tomat)o$/i, '$1oes');
+ inflect.plural(/([ti])um$/i, '$1a');
+ inflect.plural(/([ti])a$/i, '$1a');
+ inflect.plural(/sis$/i, 'ses');
+ inflect.plural(/(?:([^f])fe|([lr])f)$/i, '$1$2ves');
+ inflect.plural(/(hive)$/i, '$1s');
+ inflect.plural(/([^aeiouy]|qu)y$/i, '$1ies');
+ inflect.plural(/(x|ch|ss|sh)$/i, '$1es');
+ inflect.plural(/(matr|vert|ind)(?:ix|ex)$/i, '$1ices');
+ inflect.plural(/([m|l])ouse$/i, '$1ice');
+ inflect.plural(/([m|l])ice$/i, '$1ice');
+ inflect.plural(/^(ox)$/i, '$1en');
+ inflect.plural(/^(oxen)$/i, '$1');
+ inflect.plural(/(quiz)$/i, '$1zes');
+ inflect.singular(/s$/i, '');
+ inflect.singular(/(n)ews$/i, '$1ews');
+ inflect.singular(/([ti])a$/i, '$1um');
+ inflect.singular(/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i, '$1$2sis');
+ inflect.singular(/(^analy)ses$/i, '$1sis');
+ inflect.singular(/([^f])ves$/i, '$1fe');
+ inflect.singular(/(hive)s$/i, '$1');
+ inflect.singular(/(tive)s$/i, '$1');
+ inflect.singular(/([lr])ves$/i, '$1f');
+ inflect.singular(/([^aeiouy]|qu)ies$/i, '$1y');
+ inflect.singular(/(s)eries$/i, '$1eries');
+ inflect.singular(/(m)ovies$/i, '$1ovie');
+ inflect.singular(/(x|ch|ss|sh)es$/i, '$1');
+ inflect.singular(/([m|l])ice$/i, '$1ouse');
+ inflect.singular(/(bus)es$/i, '$1');
+ inflect.singular(/(o)es$/i, '$1');
+ inflect.singular(/(shoe)s$/i, '$1');
+ inflect.singular(/(cris|ax|test)es$/i, '$1is');
+ inflect.singular(/(octop|vir)i$/i, '$1us');
+ inflect.singular(/(alias|status)es$/i, '$1');
+ inflect.singular(/^(ox)en/i, '$1');
+ inflect.singular(/(vert|ind)ices$/i, '$1ex');
+ inflect.singular(/(matr)ices$/i, '$1ix');
+ inflect.singular(/(quiz)zes$/i, '$1');
+ inflect.singular(/(database)s$/i, '$1');
+ inflect.irregular('person', 'people');
+ inflect.irregular('man', 'men');
+ inflect.irregular('child', 'children');
+ inflect.irregular('move', 'moves');
+ inflect.irregular('she', 'they');
+ inflect.irregular('he', 'they');
+ inflect.irregular('myself', 'ourselves');
+ inflect.irregular('yourself', 'ourselves');
+ inflect.irregular('himself', 'themselves');
+ inflect.irregular('herself', 'themselves');
+ inflect.irregular('themself', 'themselves');
+ inflect.irregular('mine', 'ours');
+ inflect.irregular('hers', 'theirs');
+ inflect.irregular('his', 'theirs');
+ inflect.irregular('its', 'theirs');
+ inflect.irregular('theirs', 'theirs');
+ inflect.irregular('sex', 'sexes');
+ inflect.irregular('cow', 'kine');
+ inflect.irregular('zombie', 'zombies');
+ inflect.uncountable('advice', 'energy', 'excretion', 'digestion', 'cooperation', 'health', 'justice', 'jeans');
+ inflect.uncountable('labour', 'machinery', 'equipment', 'information', 'pollution', 'sewage', 'paper', 'money');
+ inflect.uncountable('species', 'series', 'rain', 'rice', 'fish', 'sheep', 'moose', 'deer', 'bison', 'proceedings');
+ inflect.uncountable('shears', 'pincers', 'breeches', 'hijinks', 'clippers', 'chassis', 'innings', 'elk');
+ return inflect.uncountable('rhinoceros', 'swine', 'you', 'news');
+ });
+}).call(this);
+;
+ }).call(module.exports);
+
+ __require.modules["/inflect/default_inflections.coffee"]._cached = module.exports;
+ return module.exports;
+};
+
+process.nextTick(function () {
+ var module = { exports : {} };
+ var exports = module.exports;
+ var __dirname = "/";
+ var __filename = "//Users/stefan/Desktop/projects/inflect/src";
+
+ var require = function (file) {
+ return __require(file, "/");
+ };
+ require.modules = __require.modules;
+
+ (function() {
+ module.exports = require("./inflect");
+}).call(this);
+;
+});
+
+window.inflect = require('./inflect');
View
1 client/inflect.min.js
@@ -0,0 +1 @@
+var require=function(a,b){var c=require.resolve(a,b||"/"),d=require.modules[c];if(!d)throw new Error("Failed to resolve module "+a+", tried "+c);var e=d._cached?d._cached:d();return e},__require=require;require.paths=[],require.modules={},require.extensions=[".js",".coffee"],require.resolve=function(){var a={assert:!0,events:!0,fs:!0,path:!0,vm:!0};return function(b,c){function h(a){if(require.modules[a])return a;for(var b=0;b<require.extensions.length;b++){var c=require.extensions[b];if(require.modules[a+c])return a+c}}function i(a){a=a.replace(/\/+$/,"");var b=a+"/package.json";if(require.modules[b]){var c=require.modules[b](),e=c.browserify;if(typeof e=="object"&&e.main){var f=h(d.resolve(a,e.main));if(f)return f}else if(typeof e=="string"){var f=h(d.resolve(a,e));if(f)return f}else if(c.main){var f=h(d.resolve(a,c.main));if(f)return f}}return h(a+"/index")}function j(a,b){var c=k(b);for(var d=0;d<c.length;d++){var e=c[d],f=h(e+"/"+a);if(f)return f;var g=i(e+"/"+a);if(g)return g}var f=h(a);if(f)return f}function k(a){var b;a==="/"?b=[""]:b=d.normalize(a).split("/");var c=[];for(var e=b.length-1;e>=0;e--){if(b[e]==="node_modules")continue;var f=b.slice(0,e+1).join("/")+"/node_modules";c.push(f)}return c}c||(c="/");if(a[b])return b;var d=require.modules.path(),e=c||".";if(b.match(/^(?:\.\.?\/|\/)/)){var f=h(d.resolve(e,b))||i(d.resolve(e,b));if(f)return f}var g=j(b,e);if(g)return g;throw new Error("Cannot find module '"+b+"'")}}(),require.alias=function(a,b){var c=require.modules.path(),d=null;try{d=require.resolve(a+"/package.json","/")}catch(e){d=require.resolve(a,"/")}var f=c.dirname(d),g=Object_keys(require.modules);for(var h=0;h<g.length;h++){var i=g[h];if(i.slice(0,f.length+1)===f+"/"){var j=i.slice(f.length);require.modules[b+j]=require.modules[f+j]}else i===f&&(require.modules[b]=require.modules[f])}};var Object_keys=Object.keys||function(a){var b=[];for(var c in a)b.push(c);return b};typeof process=="undefined"&&(process={}),process.nextTick||(process.nextTick=function(a){setTimeout(a,0)}),process.title||(process.title="browser"),process.binding||(process.binding=function(a){if(a==="evals")return require("vm");throw new Error("No such module")}),process.cwd||(process.cwd=function(){return"."}),require.modules.path=function(){var a={exports:{}},b=a.exports,c=".",d="path",e=function(a){return __require(a,".")};return e.resolve=function(a){return __require.resolve(name,".")},e.modules=__require.modules,__require.modules.path._cached=a.exports,function(){function a(a,b){var c=[];for(var d=0;d<a.length;d++)b(a[d],d,a)&&c.push(a[d]);return c}function c(a,b){var c=0;for(var d=a.length;d>=0;d--){var e=a[d];e=="."?a.splice(d,1):e===".."?(a.splice(d,1),c++):c&&(a.splice(d,1),c--)}if(b)for(;c--;c)a.unshift("..");return a}var d=/^(.+\/(?!$)|\/)?((?:.+?)?(\.[^.]*)?)$/;b.resolve=function(){var b="",d=!1;for(var e=arguments.length;e>=-1&&!d;e--){var f=e>=0?arguments[e]:process.cwd();if(typeof f!="string"||!f)continue;b=f+"/"+b,d=f.charAt(0)==="/"}return b=c(a(b.split("/"),function(a){return!!a}),!d).join("/"),(d?"/":"")+b||"."},b.normalize=function(b){var d=b.charAt(0)==="/",e=b.slice(-1)==="/";return b=c(a(b.split("/"),function(a){return!!a}),!d).join("/"),!b&&!d&&(b="."),b&&e&&(b+="/"),(d?"/":"")+b},b.join=function(){var c=Array.prototype.slice.call(arguments,0);return b.normalize(a(c,function(a,b){return a&&typeof a=="string"}).join("/"))},b.dirname=function(a){var b=d.exec(a)[1]||"",c=!1;return b?b.length===1||c&&b.length<=3&&b.charAt(1)===":"?b:b.substring(0,b.length-1):"."},b.basename=function(a,b){var c=d.exec(a)[2]||"";return b&&c.substr(-1*b.length)===b&&(c=c.substr(0,c.length-b.length)),c},b.extname=function(a){return d.exec(a)[3]||""}}.call(a.exports),__require.modules.path._cached=a.exports,a.exports},require.modules["/node_modules/files"]=function(){var a={exports:{}},b=a.exports,c="/node_modules",d="/node_modules/files",e=function(a){return __require(a,"/node_modules")};return e.resolve=function(a){return __require.resolve(name,"/node_modules")},e.modules=__require.modules,__require.modules["/node_modules/files"]._cached=a.exports,function(){a.exports={"package.json":'{\n "name": "inflect",\n "description": "A port of the Rails / ActiveSupport inflector to JavaScript.",\n "keywords": ["inflect", "activerecord", "rails", "activesupport", "string"],\n "version": "0.1.4",\n "author": "Stefan Huber <MSNexploder@gmail.com>",\n "homepage": "http://msnexploder.github.com/inflect/",\n "main": "lib/inflect",\n "files": [\n "Cakefile",\n "CHANGELOG.md",\n "doc",\n "lib",\n "LICENSE",\n "README.md",\n "spec",\n "src"\n ],\n "scripts": {\n "test": "cake test"\n },\n "directories": {\n "doc":"./doc",\n "lib":"./lib"\n },\n "engines": {\n "node": ">= 0.4.x <= 0.6.0"\n },\n "devDependencies": {\n "coffee-script": ">= 1.1.2 < 2.0.0",\n "docco": ">= 0.3.0 < 0.4.0",\n "vows": ">= 0.5.13 < 0.6.0",\n "browserify": ">= 1.8.1 < 1.9.0",\n "fileify": ">= 0.3.1 < 0.4.0",\n "uglify-js": ">= 1.1.1 < 1.2.0"\n },\n "repository": {\n "type": "git",\n "url": "https://github.com/MSNexploder/inflect.git"\n },\n "bugs": { "url": "https://github.com/MSNexploder/inflect/issues" },\n "licenses": [\n { "type": "MIT",\n "url": "https://github.com/MSNexploder/inflect/raw/master/LICENSE"\n }\n ]\n}'}}.call(a.exports),__require.modules["/node_modules/files"]._cached=a.exports,a.exports},require.modules["/inflect/index.coffee"]=function(){var a={exports:{}},b=a.exports,c="/inflect",d="/inflect/index.coffee",e=function(a){return __require(a,"/inflect")};return e.resolve=function(a){return __require.resolve(name,"/inflect")},e.modules=__require.modules,__require.modules["/inflect/index.coffee"]._cached=a.exports,function(){(function(){var a,c,d,f,g,h;h=e("./version"),b.package=h.package,b.version=h.version,a=e("./inflections").Inflections,c=function(b){return b!=null&&b.call(this,a.instance()),a.instance()},b.Inflections=a,b.inflections=c,d=e("./methods"),b.camelize=d.camelize,b.underscore=d.underscore,b.dasherize=d.dasherize,b.titleize=d.titleize,b.capitalize=d.capitalize,b.pluralize=d.pluralize,b.singularize=d.singularize,b.humanize=d.humanize,b.ordinalize=d.ordinalize,b.parameterize=d.parameterize,g=e("./string_extensions"),f=e("./number_extensions"),b.enableStringExtensions=g.enableStringExtensions,b.enableNumberExtensions=f.enableNumberExtensions,b.enableExtensions=function(){return g.enableStringExtensions(),f.enableNumberExtensions()},e("./default_inflections")}).call(this)}.call(a.exports),__require.modules["/inflect/index.coffee"]._cached=a.exports,a.exports},require.modules["/inflect/version.coffee"]=function(){var a={exports:{}},b=a.exports,c="/inflect",d="/inflect/version.coffee",e=function(a){return __require(a,"/inflect")};return e.resolve=function(a){return __require.resolve(name,"/inflect")},e.modules=__require.modules,__require.modules["/inflect/version.coffee"]._cached=a.exports,function(){(function(){var a,d;d=e("path"),process.title==="browser"?a=e("files")["package.json"]:a=e("fs").readFileSync(d.join(c,"/../../package.json")),b.package=JSON.parse(a),b.version=b.package.version}).call(this)}.call(a.exports),__require.modules["/inflect/version.coffee"]._cached=a.exports,a.exports},require.modules["/inflect/inflections.coffee"]=function(){var a={exports:{}},b=a.exports,c="/inflect",d="/inflect/inflections.coffee",e=function(a){return __require(a,"/inflect")};return e.resolve=function(a){return __require.resolve(name,"/inflect")},e.modules=__require.modules,__require.modules["/inflect/inflections.coffee"]._cached=a.exports,function(){(function(){var a,c=Array.prototype.slice;a=function(){function a(){this.plurals=[],this.singulars=[],this.uncountables=[],this.humans=[]}return a.instance=function(){return this.__instance__||(this.__instance__=new this)},a.prototype.plural=function(a,b){var c;return typeof a=="string"&&(c=this.uncountables.indexOf(a))!==-1&&this.uncountables.splice(c,1),(c=this.uncountables.indexOf(b))!==-1&&this.uncountables.splice(c,1),this.plurals.unshift([a,b])},a.prototype.singular=function(a,b){var c;return typeof a=="string"&&(c=this.uncountables.indexOf(a))!==-1&&this.uncountables.splice(c,1),(c=this.uncountables.indexOf(b))!==-1&&this.uncountables.splice(c,1),this.singulars.unshift([a,b])},a.prototype.irregular=function(a,b){var c;return(c=this.uncountables.indexOf(a))!==-1&&this.uncountables.splice(c,1),(c=this.uncountables.indexOf(b))!==-1&&this.uncountables.splice(c,1),a[0].toUpperCase()===b[0].toUpperCase()?(this.plural(new RegExp("("+a[0]+")"+a.slice(1)+"$","i"),"$1"+b.slice(1)),this.plural(new RegExp("("+b[0]+")"+b.slice(1)+"$","i"),"$1"+b.slice(1)),this.singular(new RegExp("("+b[0]+")"+b.slice(1)+"$","i"),"$1"+a.slice(1))):(this.plural(new RegExp(""+a[0].toUpperCase()+a.slice(1)+"$"),b[0].toUpperCase()+b.slice(1)),this.plural(new RegExp(""+a[0].toLowerCase()+a.slice(1)+"$"),b[0].toLowerCase()+b.slice(1)),this.plural(new RegExp(""+b[0].toUpperCase()+b.slice(1)+"$"),b[0].toUpperCase()+b.slice(1)),this.plural(new RegExp(""+b[0].toLowerCase()+b.slice(1)+"$"),b[0].toLowerCase()+b.slice(1)),this.singular(new RegExp(""+b[0].toUpperCase()+b.slice(1)+"$"),a[0].toUpperCase()+a.slice(1)),this.singular(new RegExp(""+b[0].toLowerCase()+b.slice(1)+"$"),a[0].toLowerCase()+a.slice(1)))},a.prototype.uncountable=function(){var a;return a=1<=arguments.length?c.call(arguments,0):[],this.uncountables=this.uncountables.concat(a)},a.prototype.human=function(a,b){return this.humans.unshift([a,b])},a.prototype.clear=function(a){return a==null&&(a="all"),a==="all"?(this.plurals=[],this.singulars=[],this.uncountables=[],this.humans=[]):this[a]=[]},a}(),b.Inflections=a}).call(this)}.call(a.exports),__require.modules["/inflect/inflections.coffee"]._cached=a.exports,a.exports},require.modules["/inflect/methods.coffee"]=function(){var a={exports:{}},b=a.exports,c="/inflect",d="/inflect/methods.coffee",e=function(a){return __require(a,"/inflect")};return e.resolve=function(a){return __require.resolve(name,"/inflect")},e.modules=__require.modules,__require.modules["/inflect/methods.coffee"]._cached=a.exports,function(){(function(){var a,c,d,f,g,h,i,j,k,l,m;g=e("../inflect").inflections,a=function(a,b){var c;return b==null&&(b=!0),c=a.replace(/_./g,function(a){return a.slice(1).toUpperCase()}),b?a[0].toUpperCase()+c.slice(1):a[0].toLowerCase()+c.slice(1)},m=function(a){var b;return b=a.toString(),b=b.replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2"),b=b.replace(/([a-z\d])([A-Z])/g,"$1_$2"),b=b.replace(/-/g,"_"),b=b.toLowerCase(),b},d=function(a){return a.replace(/_/g,"-")},l=function(a){return f(m(a)).replace(/\b('?[a-z])/g,function(a){return c(a)})},c=function(a){return(a[0]||"").toUpperCase()+(a.slice(1)||"").toLowerCase()},j=function(a){var b,c,d,e,f,h,i;d=a.toString();if(a.length===0||g().uncountables.indexOf(d.toLowerCase())!==-1)return d;i=g().plurals;for(f=0,h=i.length;f<h;f++){b=i[f],e=b[0],c=b[1];if(d.search(e)!==-1){d=d.replace(e,c);break}}return d},k=function(a){var b,c,d,e,f,h,i,j,k,l,m,n;d=a.toString(),h=!1,m=g().uncountables;for(i=0,k=m.length;i<k;i++){b=m[i];if(d.search(new RegExp("\\b"+b+"$","i"))!==-1){h=!0;break}}if(a.length===0||h)return d;n=g().singulars;for(j=0,l=n.length;j<l;j++){f=n[j],e=f[0],c=f[1];if(d.search(e)!==-1){d=d.replace(e,c);break}}return d},f=function(a){var b,d,e,f,h,i,j;e=a.toString(),j=g().humans;for(h=0,i=j.length;h<i;h++){b=j[h],f=b[0],d=b[1];if(e.search(f)!==-1){e=e.replace(f,d);break}}return c(e.replace(/_id$/,"").replace(/_/g," "))},h=function(a){var b;b=parseInt(a,10);if([11,12,13].indexOf(b%100)!==-1)return""+a+"th";switch(b%10){case 1:return""+a+"st";case 2:return""+a+"nd";case 3:return""+a+"rd";default:return""+a+"th"}},i=function(a,b){var c;return b==null&&(b="-"),c=a.toString(),c=c.replace(/[^a-z0-9\-_]+/gi,b),b!=null&&(c=c.replace(new RegExp(""+b+"{2,}","g"),b),c=c.replace(new RegExp("^"+b+"|"+b+"$","gi"),"")),c.toLowerCase()},b.camelize=a,b.underscore=m,b.dasherize=d,b.titleize=l,b.capitalize=c,b.pluralize=j,b.singularize=k,b.humanize=f,b.ordinalize=h,b.parameterize=i}).call(this)}.call(a.exports),__require.modules["/inflect/methods.coffee"]._cached=a.exports,a.exports},require.modules["/inflect/string_extensions.coffee"]=function(){var a={exports:{}},b=a.exports,c="/inflect",d="/inflect/string_extensions.coffee",e=function(a){return __require(a,"/inflect")};return e.resolve=function(a){return __require.resolve(name,"/inflect")},e.modules=__require.modules,__require.modules["/inflect/string_extensions.coffee"]._cached=a.exports,function(){(function(){var a,c;c=e("../inflect"),a=function(){return String.prototype.pluralize=function(){return c.pluralize(this)},String.prototype.singularize=function(){return c.singularize(this)},String.prototype.camelize=function(a){return a==null&&(a=!0),c.camelize(this,a)},String.prototype.capitalize=function(){return c.capitalize(this)},String.prototype.titleize=function(){return c.titleize(this)},String.prototype.underscore=function(){return c.underscore(this)},String.prototype.dasherize=function(){return c.dasherize(this)},String.prototype.parameterize=function(a){return a==null&&(a="-"),c.parameterize(this,a)},String.prototype.humanize=function(){return c.humanize(this)}},b.enableStringExtensions=a}).call(this)}.call(a.exports),__require.modules["/inflect/string_extensions.coffee"]._cached=a.exports,a.exports},require.modules["/inflect/number_extensions.coffee"]=function(){var a={exports:{}},b=a.exports,c="/inflect",d="/inflect/number_extensions.coffee",e=function(a){return __require(a,"/inflect")};return e.resolve=function(a){return __require.resolve(name,"/inflect")},e.modules=__require.modules,__require.modules["/inflect/number_extensions.coffee"]._cached=a.exports,function(){(function(){var a,c;c=e("../inflect"),a=function(){return Number.prototype.ordinalize=function(){return c.ordinalize(this)}},b.enableNumberExtensions=a}).call(this)}.call(a.exports),__require.modules["/inflect/number_extensions.coffee"]._cached=a.exports,a.exports},require.modules["/inflect/default_inflections.coffee"]=function(){var a={exports:{}},b=a.exports,c="/inflect",d="/inflect/default_inflections.coffee",e=function(a){return __require(a,"/inflect")};return e.resolve=function(a){return __require.resolve(name,"/inflect")},e.modules=__require.modules,__require.modules["/inflect/default_inflections.coffee"]._cached=a.exports,function(){(function(){var a;a=e("../inflect"),a.inflections(function(a){return a.plural(/$/,"s"),a.plural(/s$/i,"s"),a.plural(/(ax|test)is$/i,"$1es"),a.plural(/(octop|vir)us$/i,"$1i"),a.plural(/(octop|vir)i$/i,"$1i"),a.plural(/(alias|status)$/i,"$1es"),a.plural(/(bu)s$/i,"$1ses"),a.plural(/(buffal|tomat)o$/i,"$1oes"),a.plural(/([ti])um$/i,"$1a"),a.plural(/([ti])a$/i,"$1a"),a.plural(/sis$/i,"ses"),a.plural(/(?:([^f])fe|([lr])f)$/i,"$1$2ves"),a.plural(/(hive)$/i,"$1s"),a.plural(/([^aeiouy]|qu)y$/i,"$1ies"),a.plural(/(x|ch|ss|sh)$/i,"$1es"),a.plural(/(matr|vert|ind)(?:ix|ex)$/i,"$1ices"),a.plural(/([m|l])ouse$/i,"$1ice"),a.plural(/([m|l])ice$/i,"$1ice"),a.plural(/^(ox)$/i,"$1en"),a.plural(/^(oxen)$/i,"$1"),a.plural(/(quiz)$/i,"$1zes"),a.singular(/s$/i,""),a.singular(/(n)ews$/i,"$1ews"),a.singular(/([ti])a$/i,"$1um"),a.singular(/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i,"$1$2sis"),a.singular(/(^analy)ses$/i,"$1sis"),a.singular(/([^f])ves$/i,"$1fe"),a.singular(/(hive)s$/i,"$1"),a.singular(/(tive)s$/i,"$1"),a.singular(/([lr])ves$/i,"$1f"),a.singular(/([^aeiouy]|qu)ies$/i,"$1y"),a.singular(/(s)eries$/i,"$1eries"),a.singular(/(m)ovies$/i,"$1ovie"),a.singular(/(x|ch|ss|sh)es$/i,"$1"),a.singular(/([m|l])ice$/i,"$1ouse"),a.singular(/(bus)es$/i,"$1"),a.singular(/(o)es$/i,"$1"),a.singular(/(shoe)s$/i,"$1"),a.singular(/(cris|ax|test)es$/i,"$1is"),a.singular(/(octop|vir)i$/i,"$1us"),a.singular(/(alias|status)es$/i,"$1"),a.singular(/^(ox)en/i,"$1"),a.singular(/(vert|ind)ices$/i,"$1ex"),a.singular(/(matr)ices$/i,"$1ix"),a.singular(/(quiz)zes$/i,"$1"),a.singular(/(database)s$/i,"$1"),a.irregular("person","people"),a.irregular("man","men"),a.irregular("child","children"),a.irregular("move","moves"),a.irregular("she","they"),a.irregular("he","they"),a.irregular("myself","ourselves"),a.irregular("yourself","ourselves"),a.irregular("himself","themselves"),a.irregular("herself","themselves"),a.irregular("themself","themselves"),a.irregular("mine","ours"),a.irregular("hers","theirs"),a.irregular("his","theirs"),a.irregular("its","theirs"),a.irregular("theirs","theirs"),a.irregular("sex","sexes"),a.irregular("cow","kine"),a.irregular("zombie","zombies"),a.uncountable("advice","energy","excretion","digestion","cooperation","health","justice","jeans"),a.uncountable("labour","machinery","equipment","information","pollution","sewage","paper","money"),a.uncountable("species","series","rain","rice","fish","sheep","moose","deer","bison","proceedings"),a.uncountable("shears","pincers","breeches","hijinks","clippers","chassis","innings","elk"),a.uncountable("rhinoceros","swine","you","news")})}).call(this)}.call(a.exports),__require.modules["/inflect/default_inflections.coffee"]._cached=a.exports,a.exports},process.nextTick(function(){var a={exports:{}},b=a.exports,c="/",d="//Users/stefan/Desktop/projects/inflect/src",e=function(a){return __require(a,"/")};e.modules=__require.modules,function(){a.exports=e("./inflect")}.call(this)}),window.inflect=require("./inflect")
View
7 docs/version.html
@@ -1,4 +1,9 @@
-<!DOCTYPE html> <html> <head> <title>version.coffee</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" media="all" href="docco.css" /> </head> <body> <div id="container"> <div id="background"></div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="default_inflections.html"> default_inflections.coffee </a> <a class="source" href="index.html"> index.coffee </a> <a class="source" href="inflections.html"> inflections.coffee </a> <a class="source" href="methods.html"> methods.coffee </a> <a class="source" href="number_extensions.html"> number_extensions.coffee </a> <a class="source" href="string_extensions.html"> string_extensions.coffee </a> <a class="source" href="version.html"> version.coffee </a> </div> </div> </div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> version.coffee </h1> </th> <th class="code"> </th> </tr> </thead> <tbody> <tr id="section-1"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-1">&#182;</a> </div> <p>version information</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">exports.package = </span><span class="nx">JSON</span><span class="p">.</span><span class="nx">parse</span><span class="p">(</span><span class="nx">require</span><span class="p">(</span><span class="s2">&quot;fs&quot;</span><span class="p">).</span><span class="nx">readFileSync</span><span class="p">(</span><span class="nx">__dirname</span> <span class="o">+</span> <span class="s2">&quot;/../../package.json&quot;</span><span class="p">))</span>
+<!DOCTYPE html> <html> <head> <title>version.coffee</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" media="all" href="docco.css" /> </head> <body> <div id="container"> <div id="background"></div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="default_inflections.html"> default_inflections.coffee </a> <a class="source" href="index.html"> index.coffee </a> <a class="source" href="inflections.html"> inflections.coffee </a> <a class="source" href="methods.html"> methods.coffee </a> <a class="source" href="number_extensions.html"> number_extensions.coffee </a> <a class="source" href="string_extensions.html"> string_extensions.coffee </a> <a class="source" href="version.html"> version.coffee </a> </div> </div> </div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> version.coffee </h1> </th> <th class="code"> </th> </tr> </thead> <tbody> <tr id="section-1"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-1">&#182;</a> </div> </td> <td class="code"> <div class="highlight"><pre><span class="nv">path = </span><span class="nx">require</span> <span class="s1">&#39;path&#39;</span>
+
+<span class="k">if</span> <span class="nx">process</span><span class="p">.</span><span class="nx">title</span> <span class="o">==</span> <span class="s1">&#39;browser&#39;</span>
+ <span class="nv">data = </span><span class="nx">require</span><span class="p">(</span><span class="s1">&#39;files&#39;</span><span class="p">)[</span><span class="s1">&#39;package.json&#39;</span><span class="p">]</span>
+<span class="k">else</span>
+ <span class="nv">data = </span><span class="nx">require</span><span class="p">(</span><span class="s1">&#39;fs&#39;</span><span class="p">).</span><span class="nx">readFileSync</span><span class="p">(</span><span class="nx">path</span><span class="p">.</span><span class="nx">join</span><span class="p">(</span><span class="nx">__dirname</span><span class="p">,</span> <span class="s1">&#39;/../../package.json&#39;</span><span class="p">))</span></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <p>version information</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">exports.package = </span><span class="nx">JSON</span><span class="p">.</span><span class="nx">parse</span><span class="p">(</span><span class="nx">data</span><span class="p">)</span>
<span class="nv">exports.version = </span><span class="nx">exports</span><span class="p">.</span><span class="nx">package</span><span class="p">.</span><span class="nx">version</span>
</pre></div> </td> </tr> </tbody> </table> </div> </body> </html>
View
5 package.json
@@ -29,7 +29,10 @@
"devDependencies": {
"coffee-script": ">= 1.1.2 < 2.0.0",
"docco": ">= 0.3.0 < 0.4.0",
- "vows": ">= 0.5.13 < 0.6.0"
+ "vows": ">= 0.5.13 < 0.6.0",
+ "browserify": ">= 1.8.1 < 1.9.0",
+ "fileify": ">= 0.3.1 < 0.4.0",
+ "uglify-js": ">= 1.1.1 < 1.2.0"
},
"repository": {
"type": "git",
View
170 spec/client/client-spec.coffee
@@ -0,0 +1,170 @@
+module('Inflect')
+test 'pluralize plurals', ->
+ equal inflect.pluralize('plurals'), 'plurals'
+ equal inflect.pluralize('Plurals'), 'Plurals'
+
+test 'pluralize empty string', ->
+ equal inflect.pluralize(''), ''
+
+test 'uncountability', ->
+ for word in inflect.inflections().uncountable()
+ equal inflect.singularize(word), word
+ equal inflect.pluralize(word), word
+ equal inflect.singularize(word), inflect.pluralize(word)
+
+test 'uncountable word is not greedy', ->
+ uncountable_word = 'ors'
+ countable_word = 'sponsor'
+
+ cached_uncountables = inflect.inflections().uncountables
+
+ inflect.inflections().uncountable(uncountable_word)
+
+ equal(inflect.singularize(uncountable_word), uncountable_word)
+ equal(inflect.pluralize(uncountable_word), uncountable_word)
+ equal(inflect.singularize(uncountable_word), inflect.pluralize(uncountable_word))
+
+ equal(inflect.singularize(countable_word), 'sponsor')
+ equal(inflect.pluralize(countable_word), 'sponsors')
+ equal(inflect.singularize(inflect.pluralize(countable_word)), 'sponsor')
+
+ inflect.inflections().uncountables = cached_uncountables
+
+test 'pluralize singular', ->
+ for singular, plural of inflect_test_cases.singular_to_plural
+ equal(inflect.pluralize(singular), plural)
+ equal(inflect.pluralize(inflect.capitalize(singular)), inflect.capitalize(plural))
+
+test 'pluralize plural', ->
+ for singular, plural of inflect_test_cases.singular_to_plural
+ equal(inflect.pluralize(plural), plural)
+ equal(inflect.pluralize(inflect.capitalize(plural)), inflect.capitalize(plural))
+
+test 'singularize plural', ->
+ for singular, plural of inflect_test_cases.singular_to_plural
+ equal(inflect.singularize(plural), singular)
+ equal(inflect.singularize(inflect.capitalize(plural)), inflect.capitalize(singular))
+
+test 'titleize', ->
+ for before, titleized of inflect_test_cases.mixture_to_title_case
+ equal(inflect.titleize(before), titleized)
+
+test 'camelize', ->
+ for camel, underscore of inflect_test_cases.camel_to_underscore
+ equal(inflect.camelize(underscore), camel)
+
+test 'camelize with lower downcases the first letter', ->
+ equal(inflect.camelize('Capital', false), 'capital')
+
+test 'underscore', ->
+ for camel, underscore of inflect_test_cases.camel_to_underscore
+ equal(inflect.underscore(camel), underscore)
+ for camel, underscore of inflect_test_cases.camel_to_underscore_without_reverse
+ equal(inflect.underscore(camel), underscore)
+
+test 'parameterize', ->
+ for some_string, parameterized_string of inflect_test_cases.string_to_parameterized
+ equal(inflect.parameterize(some_string), parameterized_string)
+
+test 'parameterize with custom separator', ->
+ for some_string, parameterized_string of inflect_test_cases.string_to_parameterized
+ equal(inflect.parameterize(some_string, '_'), parameterized_string.replace(/-/g, '_'))
+
+test 'parameterize with multi character separator', ->
+ for some_string, parameterized_string of inflect_test_cases.string_to_parameterized
+ equal(inflect.parameterize(some_string, '__sep__'), parameterized_string.replace(/-/g, '__sep__'))
+
+test 'humanize', ->
+ for underscore, human of inflect_test_cases.underscore_to_human
+ equal(inflect.humanize(underscore), human)
+
+test 'humanize by rule', ->
+ inflect.inflections (inflect) ->
+ inflect.human(/_cnt$/i, '_count')
+ inflect.human(/^prefx_/i, '')
+ equal(inflect.humanize('jargon_cnt'), 'Jargon count')
+ equal(inflect.humanize('prefx_request'), 'Request')
+
+test 'humanize by string', ->
+ inflect.inflections (inflect) ->
+ inflect.human('col_rpted_bugs', 'Reported bugs')
+ equal(inflect.humanize('col_rpted_bugs'), 'Reported bugs')
+ equal(inflect.humanize('COL_rpted_bugs'), 'Col rpted bugs')
+
+test 'ordinal', ->
+ for number, ordinalized of inflect_test_cases.ordinal_numbers
+ equal(inflect.ordinalize(number), ordinalized)
+
+test 'dasherize', ->
+ for underscored, dasherized of inflect_test_cases.underscores_to_dashes
+ equal(inflect.dasherize(underscored), dasherized)
+
+test 'underscore as reverse of dasherize', ->
+ for underscored, dasherized of inflect_test_cases.underscores_to_dashes
+ equal(inflect.underscore(inflect.dasherize(underscored)), underscored)
+
+test 'underscore to lower camel', ->
+ for underscored, lower_camel of inflect_test_cases.underscore_to_lower_camel
+ equal(inflect.camelize(underscored, false), lower_camel)
+
+test 'overwrite previous inflectors', ->
+ equal(inflect.singularize('series'), 'series')
+ inflect.inflections().singular('series', 'serie')
+ equal(inflect.singularize('series'), 'serie')
+ inflect.inflections().uncountable('series') # Return to normal
+
+test 'clear', ->
+ for inflection_type in ['plurals', 'singulars', 'uncountables', 'humans']
+ cached_values = inflect.inflections()[inflection_type]
+ inflect.inflections().clear(inflection_type)
+ equal(inflect.inflections()[inflection_type].length, 0)
+ inflect.inflections()[inflection_type] = cached_values
+
+test 'clear all', ->
+ cached_values = {}
+ inflection_types = ['plurals', 'singulars', 'uncountables', 'humans']
+ for inflection_type in inflection_types
+ cached_values[inflection_type] = inflect.inflections()[inflection_type]
+ inflect.inflections().clear('all')
+ for inflection_type in inflection_types
+ equal(inflect.inflections()[inflection_type].length, 0)
+ inflect.inflections()[inflection_type] = cached_values[inflection_type]
+
+test 'clear with default', ->
+ cached_values = {}
+ inflection_types = ['plurals', 'singulars', 'uncountables', 'humans']
+ for inflection_type in inflection_types
+ cached_values[inflection_type] = inflect.inflections()[inflection_type]
+ inflect.inflections().clear()
+ for inflection_type in inflection_types
+ equal(inflect.inflections()[inflection_type].length, 0)
+ inflect.inflections()[inflection_type] = cached_values[inflection_type]
+
+test 'irregularity between singular and plural', ->
+ for singular, plural of inflect_test_cases.irregularities
+ inflect.inflections().irregular(singular, plural)
+ equal(inflect.singularize(plural), singular)
+ equal(inflect.pluralize(singular), plural)
+
+test 'pluralize of irregularity plural should be the same', ->
+ for singular, plural of inflect_test_cases.irregularities
+ inflect.inflections().irregular(singular, plural)
+ equal(inflect.pluralize(plural), plural)
+
+test 'register string extensions', ->
+ string_extensions = ['pluralize', 'singularize', 'capitalize', 'camelize', 'titleize', 'underscore', 'dasherize', 'parameterize', 'humanize']
+ for method in string_extensions
+ equal('inflect'[method], undefined)
+ inflect.enableStringExtensions()
+ for method in string_extensions
+ notEqual('inflect'[method], undefined)
+ equal('inflect'[method](), inflect[method]('inflect'))
+
+test 'register number extensions', ->
+ number_extensions = ['ordinalize']
+ for method in number_extensions
+ equal(123[method], undefined)
+ inflect.enableNumberExtensions()
+ for method in number_extensions
+ notEqual(123[method], undefined)
+ equal(123[method](), inflect[method](123))
View
8 spec/client/coffee-script.js
8 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
21 spec/client/index.html
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>QUnit Test Suite</title>
+ <link rel="stylesheet" href="qunit.css" type="text/css" media="screen">
+ <script type="text/javascript" src="qunit.js"></script>
+ <script type="text/javascript" src="coffee-script.js"></script>
+ <!-- Your project file goes here -->
+ <script type="text/javascript" src="../../client/inflect.js"></script>
+ <script type="text/coffeescript" src="../inflect_test_cases.coffee"></script>
+ <!-- Your tests file goes here -->
+ <script type="text/coffeescript" src="client-spec.coffee"></script>
+</head>
+<body>
+ <h1 id="qunit-header">QUnit Test Suite</h1>
+ <h2 id="qunit-banner"></h2>
+ <div id="qunit-testrunner-toolbar"></div>
+ <h2 id="qunit-userAgent"></h2>
+ <ol id="qunit-tests"></ol>
+</body>
+</html>
View
226 spec/client/qunit.css
@@ -0,0 +1,226 @@
+/**
+ * QUnit v1.3.0pre - A JavaScript Unit Testing Framework
+ *
+ * http://docs.jquery.com/QUnit
+ *
+ * Copyright (c) 2011 John Resig, Jörn Zaefferer
+ * Dual licensed under the MIT (MIT-LICENSE.txt)
+ * or GPL (GPL-LICENSE.txt) licenses.
+ */
+
+/** Font Family and Sizes */
+
+#qunit-tests, #qunit-header, #qunit-banner, #qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult {
+ font-family: "Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial, sans-serif;
+}
+
+#qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult, #qunit-tests li { font-size: small; }
+#qunit-tests { font-size: smaller; }
+
+
+/** Resets */
+
+#qunit-tests, #qunit-tests ol, #qunit-header, #qunit-banner, #qunit-userAgent, #qunit-testresult {
+ margin: 0;
+ padding: 0;
+}
+
+
+/** Header */
+
+#qunit-header {
+ padding: 0.5em 0 0.5em 1em;
+
+ color: #8699a4;
+ background-color: #0d3349;
+
+ font-size: 1.5em;
+ line-height: 1em;
+ font-weight: normal;
+
+ border-radius: 15px 15px 0 0;
+ -moz-border-radius: 15px 15px 0 0;
+ -webkit-border-top-right-radius: 15px;
+ -webkit-border-top-left-radius: 15px;
+}
+
+#qunit-header a {
+ text-decoration: none;
+ color: #c2ccd1;
+}
+
+#qunit-header a:hover,
+#qunit-header a:focus {
+ color: #fff;
+}
+
+#qunit-banner {
+ height: 5px;
+}
+
+#qunit-testrunner-toolbar {
+ padding: 0.5em 0 0.5em 2em;
+ color: #5E740B;
+ background-color: #eee;
+}
+
+#qunit-userAgent {
+ padding: 0.5em 0 0.5em 2.5em;
+ background-color: #2b81af;
+ color: #fff;
+ text-shadow: rgba(0, 0, 0, 0.5) 2px 2px 1px;
+}
+
+
+/** Tests: Pass/Fail */
+
+#qunit-tests {
+ list-style-position: inside;
+}
+
+#qunit-tests li {
+ padding: 0.4em 0.5em 0.4em 2.5em;
+ border-bottom: 1px solid #fff;
+ list-style-position: inside;
+}
+
+#qunit-tests.hidepass li.pass, #qunit-tests.hidepass li.running {
+ display: none;
+}
+
+#qunit-tests li strong {
+ cursor: pointer;
+}
+
+#qunit-tests li a {
+ padding: 0.5em;
+ color: #c2ccd1;
+ text-decoration: none;
+}
+#qunit-tests li a:hover,
+#qunit-tests li a:focus {
+ color: #000;
+}
+
+#qunit-tests ol {
+ margin-top: 0.5em;
+ padding: 0.5em;
+
+ background-color: #fff;
+
+ border-radius: 15px;
+ -moz-border-radius: 15px;
+ -webkit-border-radius: 15px;
+
+ box-shadow: inset 0px 2px 13px #999;
+ -moz-box-shadow: inset 0px 2px 13px #999;
+ -webkit-box-shadow: inset 0px 2px 13px #999;
+}
+
+#qunit-tests table {
+ border-collapse: collapse;
+ margin-top: .2em;
+}
+
+#qunit-tests th {
+ text-align: right;
+ vertical-align: top;
+ padding: 0 .5em 0 0;
+}
+
+#qunit-tests td {
+ vertical-align: top;
+}
+
+#qunit-tests pre {
+ margin: 0;
+ white-space: pre-wrap;
+ word-wrap: break-word;
+}
+
+#qunit-tests del {
+ background-color: #e0f2be;
+ color: #374e0c;
+ text-decoration: none;
+}
+
+#qunit-tests ins {
+ background-color: #ffcaca;
+ color: #500;
+ text-decoration: none;
+}
+
+/*** Test Counts */
+
+#qunit-tests b.counts { color: black; }
+#qunit-tests b.passed { color: #5E740B; }
+#qunit-tests b.failed { color: #710909; }
+
+#qunit-tests li li {
+ margin: 0.5em;
+ padding: 0.4em 0.5em 0.4em 0.5em;
+ background-color: #fff;
+ border-bottom: none;
+ list-style-position: inside;
+}
+
+/*** Passing Styles */
+
+#qunit-tests li li.pass {
+ color: #5E740B;
+ background-color: #fff;
+ border-left: 26px solid #C6E746;
+}
+
+#qunit-tests .pass { color: #528CE0; background-color: #D2E0E6; }
+#qunit-tests .pass .test-name { color: #366097; }
+
+#qunit-tests .pass .test-actual,
+#qunit-tests .pass .test-expected { color: #999999; }
+
+#qunit-banner.qunit-pass { background-color: #C6E746; }
+
+/*** Failing Styles */
+
+#qunit-tests li li.fail {
+ color: #710909;
+ background-color: #fff;
+ border-left: 26px solid #EE5757;
+ white-space: pre;
+}
+
+#qunit-tests > li:last-child {
+ border-radius: 0 0 15px 15px;
+ -moz-border-radius: 0 0 15px 15px;
+ -webkit-border-bottom-right-radius: 15px;
+ -webkit-border-bottom-left-radius: 15px;
+}
+
+#qunit-tests .fail { color: #000000; background-color: #EE5757; }
+#qunit-tests .fail .test-name,
+#qunit-tests .fail .module-name { color: #000000; }
+
+#qunit-tests .fail .test-actual { color: #EE5757; }
+#qunit-tests .fail .test-expected { color: green; }
+
+#qunit-banner.qunit-fail { background-color: #EE5757; }
+
+
+/** Result */
+
+#qunit-testresult {
+ padding: 0.5em 0.5em 0.5em 2.5em;
+
+ color: #2b81af;
+ background-color: #D2E0E6;
+
+ border-bottom: 1px solid white;
+}
+
+/** Fixture */
+
+#qunit-fixture {
+ position: absolute;
+ top: -10000px;
+ left: -10000px;
+}
View
1,597 spec/client/qunit.js
1,597 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
409 spec/inflect_test_cases.coffee
@@ -1,203 +1,210 @@
-exports.singular_to_plural = {
- "search" : "searches",
- "switch" : "switches",
- "fix" : "fixes",
- "box" : "boxes",
- "process" : "processes",
- "address" : "addresses",
- "case" : "cases",
- "stack" : "stacks",
- "wish" : "wishes",
- "fish" : "fish",
- "jeans" : "jeans",
- "funky jeans" : "funky jeans",
-
- "category" : "categories",
- "query" : "queries",
- "ability" : "abilities",
- "agency" : "agencies",
- "movie" : "movies",
-
- "archive" : "archives",
-
- "index" : "indices",
-
- "wife" : "wives",
- "safe" : "saves",
- "half" : "halves",
-
- "move" : "moves",
-
- "salesperson" : "salespeople",
- "person" : "people",
-
- "spokesman" : "spokesmen",
- "man" : "men",
- "woman" : "women",
-
- "basis" : "bases",
- "diagnosis" : "diagnoses",
- "diagnosis_a" : "diagnosis_as",
-
- "datum" : "data",
- "medium" : "media",
- "stadium" : "stadia",
- "analysis" : "analyses",
-
- "node_child" : "node_children",
- "child" : "children",
-
- "experience" : "experiences",
- "day" : "days",
-
- "comment" : "comments",
- "foobar" : "foobars",
- "newsletter" : "newsletters",
-
- "old_news" : "old_news",
- "news" : "news",
-
- "series" : "series",
- "species" : "species",
-
- "quiz" : "quizzes",
-
- "perspective" : "perspectives",
-
- "ox" : "oxen",
- "photo" : "photos",
- "buffalo" : "buffaloes",
- "tomato" : "tomatoes",
- "dwarf" : "dwarves",
- "elf" : "elves",
- "information" : "information",
- "equipment" : "equipment",
- "bus" : "buses",
- "status" : "statuses",
- "status_code" : "status_codes",
- "mouse" : "mice",
-
- "louse" : "lice",
- "house" : "houses",
- "octopus" : "octopi",
- "virus" : "viri",
- "alias" : "aliases",
- "portfolio" : "portfolios",
-
- "vertex" : "vertices",
- "matrix" : "matrices",
- "matrix_fu" : "matrix_fus",
-
- "axis" : "axes",
- "testis" : "testes",
- "crisis" : "crises",
-
- "rice" : "rice",
- "shoe" : "shoes",
-
- "horse" : "horses",
- "prize" : "prizes",
- "edge" : "edges",
-
- "cow" : "kine",
- "database" : "databases"
+test_data = {
+ singular_to_plural: {
+ "search" : "searches",
+ "switch" : "switches",
+ "fix" : "fixes",
+ "box" : "boxes",
+ "process" : "processes",
+ "address" : "addresses",
+ "case" : "cases",
+ "stack" : "stacks",
+ "wish" : "wishes",
+ "fish" : "fish",
+ "jeans" : "jeans",
+ "funky jeans" : "funky jeans",
+
+ "category" : "categories",
+ "query" : "queries",
+ "ability" : "abilities",
+ "agency" : "agencies",
+ "movie" : "movies",
+
+ "archive" : "archives",
+
+ "index" : "indices",
+
+ "wife" : "wives",
+ "safe" : "saves",
+ "half" : "halves",
+
+ "move" : "moves",
+
+ "salesperson" : "salespeople",
+ "person" : "people",
+
+ "spokesman" : "spokesmen",
+ "man" : "men",
+ "woman" : "women",
+
+ "basis" : "bases",
+ "diagnosis" : "diagnoses",
+ "diagnosis_a" : "diagnosis_as",
+
+ "datum" : "data",
+ "medium" : "media",
+ "stadium" : "stadia",
+ "analysis" : "analyses",
+
+ "node_child" : "node_children",
+ "child" : "children",
+
+ "experience" : "experiences",
+ "day" : "days",
+
+ "comment" : "comments",
+ "foobar" : "foobars",
+ "newsletter" : "newsletters",
+
+ "old_news" : "old_news",
+ "news" : "news",
+
+ "series" : "series",
+ "species" : "species",
+
+ "quiz" : "quizzes",
+
+ "perspective" : "perspectives",
+
+ "ox" : "oxen",
+ "photo" : "photos",
+ "buffalo" : "buffaloes",
+ "tomato" : "tomatoes",
+ "dwarf" : "dwarves",
+ "elf" : "elves",
+ "information" : "information",
+ "equipment" : "equipment",
+ "bus" : "buses",
+ "status" : "statuses",
+ "status_code" : "status_codes",
+ "mouse" : "mice",
+
+ "louse" : "lice",
+ "house" : "houses",
+ "octopus" : "octopi",
+ "virus" : "viri",
+ "alias" : "aliases",
+ "portfolio" : "portfolios",
+
+ "vertex" : "vertices",
+ "matrix" : "matrices",
+ "matrix_fu" : "matrix_fus",
+
+ "axis" : "axes",
+ "testis" : "testes",
+ "crisis" : "crises",
+
+ "rice" : "rice",
+ "shoe" : "shoes",
+
+ "horse" : "horses",
+ "prize" : "prizes",
+ "edge" : "edges",
+
+ "cow" : "kine",
+ "database" : "databases"
+ }
+
+ camel_to_underscore: {
+ "Product" : "product",
+ "SpecialGuest" : "special_guest",
+ "ApplicationController" : "application_controller",
+ "Area51Controller" : "area51_controller"
+ }
+
+ underscore_to_lower_camel: {
+ "product" : "product",
+ "special_guest" : "specialGuest",
+ "application_controller" : "applicationController",
+ "area51_controller" : "area51Controller"
+ }
+
+ camel_to_underscore_without_reverse: {
+ "HTMLTidy" : "html_tidy",
+ "HTMLTidyGenerator" : "html_tidy_generator",
+ "FreeBSD" : "free_bsd",
+ "HTML" : "html",
+ }
+
+ string_to_parameterized: {
+ "Donald E. Knuth" : "donald-e-knuth",
+ "Random text with *(bad)* characters" : "random-text-with-bad-characters",
+ "Allow_Under_Scores" : "allow_under_scores",
+ "Trailing bad characters!@#" : "trailing-bad-characters",
+ "!@#Leading bad characters" : "leading-bad-characters",
+ "Squeeze separators" : "squeeze-separators",
+ "Test with + sign" : "test-with-sign",
+ "Test with malformed utf8 \251" : "test-with-malformed-utf8"
+ }
+
+ underscore_to_human: {
+ "employee_salary" : "Employee salary",
+ "employee_id" : "Employee",
+ "underground" : "Underground"
+ }
+
+ mixture_to_title_case: {
+ 'active_record' : 'Active Record',
+ 'ActiveRecord' : 'Active Record',
+ 'action web service' : 'Action Web Service',
+ 'Action Web Service' : 'Action Web Service',
+ 'Action web service' : 'Action Web Service',
+ 'actionwebservice' : 'Actionwebservice',
+ 'Actionwebservice' : 'Actionwebservice',
+ "david's code" : "David's Code",
+ "David's code" : "David's Code",
+ "david's Code" : "David's Code"
+ }
+
+ ordinal_numbers: {
+ "0" : "0th",
+ "1" : "1st",
+ "2" : "2nd",
+ "3" : "3rd",
+ "4" : "4th",
+ "5" : "5th",
+ "6" : "6th",
+ "7" : "7th",
+ "8" : "8th",
+ "9" : "9th",
+ "10" : "10th",
+ "11" : "11th",
+ "12" : "12th",
+ "13" : "13th",
+ "14" : "14th",
+ "20" : "20th",
+ "21" : "21st",
+ "22" : "22nd",
+ "23" : "23rd",
+ "24" : "24th",
+ "100" : "100th",
+ "101" : "101st",
+ "102" : "102nd",
+ "103" : "103rd",
+ "104" : "104th",
+ "110" : "110th",
+ "111" : "111th",
+ "112" : "112th",
+ "113" : "113th",
+ "1000" : "1000th",
+ "1001" : "1001st"
+ }
+
+ underscores_to_dashes: {
+ "street" : "street",
+ "street_address" : "street-address",
+ "person_street_address" : "person-street-address"
+ }
+
+ irregularities: {
+ 'person' : 'people',
+ 'man' : 'men',
+ 'child' : 'children',
+ 'sex' : 'sexes',
+ 'move' : 'moves',
+ }
}
-exports.camel_to_underscore = {
- "Product" : "product",
- "SpecialGuest" : "special_guest",
- "ApplicationController" : "application_controller",
- "Area51Controller" : "area51_controller"
-}
-
-exports.underscore_to_lower_camel = {
- "product" : "product",
- "special_guest" : "specialGuest",
- "application_controller" : "applicationController",
- "area51_controller" : "area51Controller"
-}
-
-exports.camel_to_underscore_without_reverse = {
- "HTMLTidy" : "html_tidy",
- "HTMLTidyGenerator" : "html_tidy_generator",
- "FreeBSD" : "free_bsd",
- "HTML" : "html",
-}
-
-exports.string_to_parameterized = {
- "Donald E. Knuth" : "donald-e-knuth",
- "Random text with *(bad)* characters" : "random-text-with-bad-characters",
- "Allow_Under_Scores" : "allow_under_scores",
- "Trailing bad characters!@#" : "trailing-bad-characters",
- "!@#Leading bad characters" : "leading-bad-characters",
- "Squeeze separators" : "squeeze-separators",
- "Test with + sign" : "test-with-sign",
- "Test with malformed utf8 \251" : "test-with-malformed-utf8"
-}
-
-exports.underscore_to_human = {
- "employee_salary" : "Employee salary",
- "employee_id" : "Employee",
- "underground" : "Underground"
-}
-
-exports.mixture_to_title_case = {
- 'active_record' : 'Active Record',
- 'ActiveRecord' : 'Active Record',
- 'action web service' : 'Action Web Service',
- 'Action Web Service' : 'Action Web Service',
- 'Action web service' : 'Action Web Service',
- 'actionwebservice' : 'Actionwebservice',
- 'Actionwebservice' : 'Actionwebservice',
- "david's code" : "David's Code",
- "David's code" : "David's Code",
- "david's Code" : "David's Code"
-}
-
-exports.ordinal_numbers = {
- "0" : "0th",
- "1" : "1st",
- "2" : "2nd",
- "3" : "3rd",
- "4" : "4th",
- "5" : "5th",
- "6" : "6th",
- "7" : "7th",
- "8" : "8th",
- "9" : "9th",
- "10" : "10th",
- "11" : "11th",
- "12" : "12th",
- "13" : "13th",
- "14" : "14th",
- "20" : "20th",
- "21" : "21st",
- "22" : "22nd",
- "23" : "23rd",
- "24" : "24th",
- "100" : "100th",
- "101" : "101st",
- "102" : "102nd",
- "103" : "103rd",
- "104" : "104th",
- "110" : "110th",
- "111" : "111th",
- "112" : "112th",
- "113" : "113th",
- "1000" : "1000th",
- "1001" : "1001st"
-}
-
-exports.underscores_to_dashes = {
- "street" : "street",
- "street_address" : "street-address",
- "person_street_address" : "person-street-address"
-}
-
-exports.irregularities = {
- 'person' : 'people',
- 'man' : 'men',
- 'child' : 'children',
- 'sex' : 'sexes',
- 'move' : 'moves',
-}
+if process.title == 'browser'
+ window.inflect_test_cases = test_data
+else
+ module.exports = test_data
View
7 src/inflect/version.coffee
@@ -1,5 +1,10 @@
path = require 'path'
+if process.title == 'browser'
+ data = require('files')['package.json']
+else
+ data = require('fs').readFileSync(path.join(__dirname, '/../../package.json'))
+
# version information
-exports.package = JSON.parse(require('fs').readFileSync(path.join(__dirname, '/../../package.json')))
+exports.package = JSON.parse(data)
exports.version = exports.package.version

0 comments on commit 65042f8

Please sign in to comment.
Something went wrong with that request. Please try again.