neat-rails 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/lib/neat/rails/engine.rb +7 -0
- data/lib/neat/rails/version.rb +5 -0
- data/lib/neat-rails.rb +7 -0
- data/neat-rails.gemspec +21 -0
- data/vendor/assets/javascripts/neat/collection_editor.coffee +215 -0
- data/vendor/assets/javascripts/neat/lib/delayed_action.js +49 -0
- data/vendor/assets/javascripts/neat/lib/inflect.js +825 -0
- data/vendor/assets/javascripts/neat/lib/jquery_extensions.coffee +15 -0
- data/vendor/assets/javascripts/neat/lib/paginated_list.js +204 -0
- data/vendor/assets/javascripts/neat/model_editor.coffee +107 -0
- data/vendor/assets/javascripts/neat.js +23 -0
- metadata +75 -0
@@ -0,0 +1,825 @@
|
|
1
|
+
// https://github.com/MSNexploder/inflect
|
2
|
+
|
3
|
+
var require = function (file, cwd) {
|
4
|
+
var resolved = require.resolve(file, cwd || '/');
|
5
|
+
var mod = require.modules[resolved];
|
6
|
+
if (!mod) throw new Error(
|
7
|
+
'Failed to resolve module ' + file + ', tried ' + resolved
|
8
|
+
);
|
9
|
+
var res = mod._cached ? mod._cached : mod();
|
10
|
+
return res;
|
11
|
+
}
|
12
|
+
|
13
|
+
require.paths = [];
|
14
|
+
require.modules = {};
|
15
|
+
require.extensions = [".js",".coffee"];
|
16
|
+
|
17
|
+
require._core = {
|
18
|
+
'assert': true,
|
19
|
+
'events': true,
|
20
|
+
'fs': true,
|
21
|
+
'path': true,
|
22
|
+
'vm': true
|
23
|
+
};
|
24
|
+
|
25
|
+
require.resolve = (function () {
|
26
|
+
return function (x, cwd) {
|
27
|
+
if (!cwd) cwd = '/';
|
28
|
+
|
29
|
+
if (require._core[x]) return x;
|
30
|
+
var path = require.modules.path();
|
31
|
+
var y = cwd || '.';
|
32
|
+
|
33
|
+
if (x.match(/^(?:\.\.?\/|\/)/)) {
|
34
|
+
var m = loadAsFileSync(path.resolve(y, x))
|
35
|
+
|| loadAsDirectorySync(path.resolve(y, x));
|
36
|
+
if (m) return m;
|
37
|
+
}
|
38
|
+
|
39
|
+
var n = loadNodeModulesSync(x, y);
|
40
|
+
if (n) return n;
|
41
|
+
|
42
|
+
throw new Error("Cannot find module '" + x + "'");
|
43
|
+
|
44
|
+
function loadAsFileSync (x) {
|
45
|
+
if (require.modules[x]) {
|
46
|
+
return x;
|
47
|
+
}
|
48
|
+
|
49
|
+
for (var i = 0; i < require.extensions.length; i++) {
|
50
|
+
var ext = require.extensions[i];
|
51
|
+
if (require.modules[x + ext]) return x + ext;
|
52
|
+
}
|
53
|
+
}
|
54
|
+
|
55
|
+
function loadAsDirectorySync (x) {
|
56
|
+
x = x.replace(/\/+$/, '');
|
57
|
+
var pkgfile = x + '/package.json';
|
58
|
+
if (require.modules[pkgfile]) {
|
59
|
+
var pkg = require.modules[pkgfile]();
|
60
|
+
var b = pkg.browserify;
|
61
|
+
if (typeof b === 'object' && b.main) {
|
62
|
+
var m = loadAsFileSync(path.resolve(x, b.main));
|
63
|
+
if (m) return m;
|
64
|
+
}
|
65
|
+
else if (typeof b === 'string') {
|
66
|
+
var m = loadAsFileSync(path.resolve(x, b));
|
67
|
+
if (m) return m;
|
68
|
+
}
|
69
|
+
else if (pkg.main) {
|
70
|
+
var m = loadAsFileSync(path.resolve(x, pkg.main));
|
71
|
+
if (m) return m;
|
72
|
+
}
|
73
|
+
}
|
74
|
+
|
75
|
+
return loadAsFileSync(x + '/index');
|
76
|
+
}
|
77
|
+
|
78
|
+
function loadNodeModulesSync (x, start) {
|
79
|
+
var dirs = nodeModulesPathsSync(start);
|
80
|
+
for (var i = 0; i < dirs.length; i++) {
|
81
|
+
var dir = dirs[i];
|
82
|
+
var m = loadAsFileSync(dir + '/' + x);
|
83
|
+
if (m) return m;
|
84
|
+
var n = loadAsDirectorySync(dir + '/' + x);
|
85
|
+
if (n) return n;
|
86
|
+
}
|
87
|
+
|
88
|
+
var m = loadAsFileSync(x);
|
89
|
+
if (m) return m;
|
90
|
+
}
|
91
|
+
|
92
|
+
function nodeModulesPathsSync (start) {
|
93
|
+
var parts;
|
94
|
+
if (start === '/') parts = [ '' ];
|
95
|
+
else parts = path.normalize(start).split('/');
|
96
|
+
|
97
|
+
var dirs = [];
|
98
|
+
for (var i = parts.length - 1; i >= 0; i--) {
|
99
|
+
if (parts[i] === 'node_modules') continue;
|
100
|
+
var dir = parts.slice(0, i + 1).join('/') + '/node_modules';
|
101
|
+
dirs.push(dir);
|
102
|
+
}
|
103
|
+
|
104
|
+
return dirs;
|
105
|
+
}
|
106
|
+
};
|
107
|
+
})();
|
108
|
+
|
109
|
+
require.alias = function (from, to) {
|
110
|
+
var path = require.modules.path();
|
111
|
+
var res = null;
|
112
|
+
try {
|
113
|
+
res = require.resolve(from + '/package.json', '/');
|
114
|
+
}
|
115
|
+
catch (err) {
|
116
|
+
res = require.resolve(from, '/');
|
117
|
+
}
|
118
|
+
var basedir = path.dirname(res);
|
119
|
+
|
120
|
+
var keys = Object_keys(require.modules);
|
121
|
+
|
122
|
+
for (var i = 0; i < keys.length; i++) {
|
123
|
+
var key = keys[i];
|
124
|
+
if (key.slice(0, basedir.length + 1) === basedir + '/') {
|
125
|
+
var f = key.slice(basedir.length);
|
126
|
+
require.modules[to + f] = require.modules[basedir + f];
|
127
|
+
}
|
128
|
+
else if (key === basedir) {
|
129
|
+
require.modules[to] = require.modules[basedir];
|
130
|
+
}
|
131
|
+
}
|
132
|
+
};
|
133
|
+
|
134
|
+
require.define = function (filename, fn) {
|
135
|
+
var dirname = require._core[filename]
|
136
|
+
? ''
|
137
|
+
: require.modules.path().dirname(filename)
|
138
|
+
;
|
139
|
+
|
140
|
+
var require_ = function (file) {
|
141
|
+
return require(file, dirname)
|
142
|
+
};
|
143
|
+
require_.resolve = function (name) {
|
144
|
+
return require.resolve(name, dirname);
|
145
|
+
};
|
146
|
+
require_.modules = require.modules;
|
147
|
+
require_.define = require.define;
|
148
|
+
var module_ = { exports : {} };
|
149
|
+
|
150
|
+
require.modules[filename] = function () {
|
151
|
+
require.modules[filename]._cached = module_.exports;
|
152
|
+
fn.call(
|
153
|
+
module_.exports,
|
154
|
+
require_,
|
155
|
+
module_,
|
156
|
+
module_.exports,
|
157
|
+
dirname,
|
158
|
+
filename
|
159
|
+
);
|
160
|
+
require.modules[filename]._cached = module_.exports;
|
161
|
+
return module_.exports;
|
162
|
+
};
|
163
|
+
};
|
164
|
+
|
165
|
+
var Object_keys = Object.keys || function (obj) {
|
166
|
+
var res = [];
|
167
|
+
for (var key in obj) res.push(key)
|
168
|
+
return res;
|
169
|
+
};
|
170
|
+
|
171
|
+
if (typeof process === 'undefined') process = {};
|
172
|
+
|
173
|
+
if (!process.nextTick) process.nextTick = function (fn) {
|
174
|
+
setTimeout(fn, 0);
|
175
|
+
};
|
176
|
+
|
177
|
+
if (!process.title) process.title = 'browser';
|
178
|
+
|
179
|
+
if (!process.binding) process.binding = function (name) {
|
180
|
+
if (name === 'evals') return require('vm')
|
181
|
+
else throw new Error('No such module')
|
182
|
+
};
|
183
|
+
|
184
|
+
if (!process.cwd) process.cwd = function () { return '.' };
|
185
|
+
|
186
|
+
require.define("path", function (require, module, exports, __dirname, __filename) {
|
187
|
+
function filter (xs, fn) {
|
188
|
+
var res = [];
|
189
|
+
for (var i = 0; i < xs.length; i++) {
|
190
|
+
if (fn(xs[i], i, xs)) res.push(xs[i]);
|
191
|
+
}
|
192
|
+
return res;
|
193
|
+
}
|
194
|
+
|
195
|
+
// resolves . and .. elements in a path array with directory names there
|
196
|
+
// must be no slashes, empty elements, or device names (c:\) in the array
|
197
|
+
// (so also no leading and trailing slashes - it does not distinguish
|
198
|
+
// relative and absolute paths)
|
199
|
+
function normalizeArray(parts, allowAboveRoot) {
|
200
|
+
// if the path tries to go above the root, `up` ends up > 0
|
201
|
+
var up = 0;
|
202
|
+
for (var i = parts.length; i >= 0; i--) {
|
203
|
+
var last = parts[i];
|
204
|
+
if (last == '.') {
|
205
|
+
parts.splice(i, 1);
|
206
|
+
} else if (last === '..') {
|
207
|
+
parts.splice(i, 1);
|
208
|
+
up++;
|
209
|
+
} else if (up) {
|
210
|
+
parts.splice(i, 1);
|
211
|
+
up--;
|
212
|
+
}
|
213
|
+
}
|
214
|
+
|
215
|
+
// if the path is allowed to go above the root, restore leading ..s
|
216
|
+
if (allowAboveRoot) {
|
217
|
+
for (; up--; up) {
|
218
|
+
parts.unshift('..');
|
219
|
+
}
|
220
|
+
}
|
221
|
+
|
222
|
+
return parts;
|
223
|
+
}
|
224
|
+
|
225
|
+
// Regex to split a filename into [*, dir, basename, ext]
|
226
|
+
// posix version
|
227
|
+
var splitPathRe = /^(.+\/(?!$)|\/)?((?:.+?)?(\.[^.]*)?)$/;
|
228
|
+
|
229
|
+
// path.resolve([from ...], to)
|
230
|
+
// posix version
|
231
|
+
exports.resolve = function() {
|
232
|
+
var resolvedPath = '',
|
233
|
+
resolvedAbsolute = false;
|
234
|
+
|
235
|
+
for (var i = arguments.length; i >= -1 && !resolvedAbsolute; i--) {
|
236
|
+
var path = (i >= 0)
|
237
|
+
? arguments[i]
|
238
|
+
: process.cwd();
|
239
|
+
|
240
|
+
// Skip empty and invalid entries
|
241
|
+
if (typeof path !== 'string' || !path) {
|
242
|
+
continue;
|
243
|
+
}
|
244
|
+
|
245
|
+
resolvedPath = path + '/' + resolvedPath;
|
246
|
+
resolvedAbsolute = path.charAt(0) === '/';
|
247
|
+
}
|
248
|
+
|
249
|
+
// At this point the path should be resolved to a full absolute path, but
|
250
|
+
// handle relative paths to be safe (might happen when process.cwd() fails)
|
251
|
+
|
252
|
+
// Normalize the path
|
253
|
+
resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {
|
254
|
+
return !!p;
|
255
|
+
}), !resolvedAbsolute).join('/');
|
256
|
+
|
257
|
+
return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
|
258
|
+
};
|
259
|
+
|
260
|
+
// path.normalize(path)
|
261
|
+
// posix version
|
262
|
+
exports.normalize = function(path) {
|
263
|
+
var isAbsolute = path.charAt(0) === '/',
|
264
|
+
trailingSlash = path.slice(-1) === '/';
|
265
|
+
|
266
|
+
// Normalize the path
|
267
|
+
path = normalizeArray(filter(path.split('/'), function(p) {
|
268
|
+
return !!p;
|
269
|
+
}), !isAbsolute).join('/');
|
270
|
+
|
271
|
+
if (!path && !isAbsolute) {
|
272
|
+
path = '.';
|
273
|
+
}
|
274
|
+
if (path && trailingSlash) {
|
275
|
+
path += '/';
|
276
|
+
}
|
277
|
+
|
278
|
+
return (isAbsolute ? '/' : '') + path;
|
279
|
+
};
|
280
|
+
|
281
|
+
|
282
|
+
// posix version
|
283
|
+
exports.join = function() {
|
284
|
+
var paths = Array.prototype.slice.call(arguments, 0);
|
285
|
+
return exports.normalize(filter(paths, function(p, index) {
|
286
|
+
return p && typeof p === 'string';
|
287
|
+
}).join('/'));
|
288
|
+
};
|
289
|
+
|
290
|
+
|
291
|
+
exports.dirname = function(path) {
|
292
|
+
var dir = splitPathRe.exec(path)[1] || '';
|
293
|
+
var isWindows = false;
|
294
|
+
if (!dir) {
|
295
|
+
// No dirname
|
296
|
+
return '.';
|
297
|
+
} else if (dir.length === 1 ||
|
298
|
+
(isWindows && dir.length <= 3 && dir.charAt(1) === ':')) {
|
299
|
+
// It is just a slash or a drive letter with a slash
|
300
|
+
return dir;
|
301
|
+
} else {
|
302
|
+
// It is a full dirname, strip trailing slash
|
303
|
+
return dir.substring(0, dir.length - 1);
|
304
|
+
}
|
305
|
+
};
|
306
|
+
|
307
|
+
|
308
|
+
exports.basename = function(path, ext) {
|
309
|
+
var f = splitPathRe.exec(path)[2] || '';
|
310
|
+
// TODO: make this comparison case-insensitive on windows?
|
311
|
+
if (ext && f.substr(-1 * ext.length) === ext) {
|
312
|
+
f = f.substr(0, f.length - ext.length);
|
313
|
+
}
|
314
|
+
return f;
|
315
|
+
};
|
316
|
+
|
317
|
+
|
318
|
+
exports.extname = function(path) {
|
319
|
+
return splitPathRe.exec(path)[3] || '';
|
320
|
+
};
|
321
|
+
|
322
|
+
});
|
323
|
+
|
324
|
+
require.define("/node_modules/files", function (require, module, exports, __dirname, __filename) {
|
325
|
+
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.2.0\",\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.x\"\n },\n \"devDependencies\": {\n \"coffee-script\": \">= 1.1.2 < 2.0.0\",\n \"docco\": \">= 0.3.0 < 0.4.0\",\n \"vows\": \">= 0.6.0 < 0.7.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}"}
|
326
|
+
|
327
|
+
});
|
328
|
+
|
329
|
+
require.define("/inflect/index.coffee", function (require, module, exports, __dirname, __filename) {
|
330
|
+
(function() {
|
331
|
+
var Inflections, inflections, methods, number_extensions, string_extensions, version;
|
332
|
+
|
333
|
+
version = require('./version');
|
334
|
+
|
335
|
+
exports.package = version.package;
|
336
|
+
|
337
|
+
exports.version = version.version;
|
338
|
+
|
339
|
+
Inflections = require('./inflections').Inflections;
|
340
|
+
|
341
|
+
inflections = function(callback) {
|
342
|
+
if (callback != null) callback.call(this, Inflections.instance());
|
343
|
+
return Inflections.instance();
|
344
|
+
};
|
345
|
+
|
346
|
+
exports.Inflections = Inflections;
|
347
|
+
|
348
|
+
exports.inflections = inflections;
|
349
|
+
|
350
|
+
methods = require('./methods');
|
351
|
+
|
352
|
+
exports.camelize = methods.camelize;
|
353
|
+
|
354
|
+
exports.underscore = methods.underscore;
|
355
|
+
|
356
|
+
exports.dasherize = methods.dasherize;
|
357
|
+
|
358
|
+
exports.titleize = methods.titleize;
|
359
|
+
|
360
|
+
exports.capitalize = methods.capitalize;
|
361
|
+
|
362
|
+
exports.pluralize = methods.pluralize;
|
363
|
+
|
364
|
+
exports.singularize = methods.singularize;
|
365
|
+
|
366
|
+
exports.humanize = methods.humanize;
|
367
|
+
|
368
|
+
exports.ordinalize = methods.ordinalize;
|
369
|
+
|
370
|
+
exports.parameterize = methods.parameterize;
|
371
|
+
|
372
|
+
string_extensions = require('./string_extensions');
|
373
|
+
|
374
|
+
number_extensions = require('./number_extensions');
|
375
|
+
|
376
|
+
exports.enableStringExtensions = string_extensions.enableStringExtensions;
|
377
|
+
|
378
|
+
exports.enableNumberExtensions = number_extensions.enableNumberExtensions;
|
379
|
+
|
380
|
+
exports.enableExtensions = function() {
|
381
|
+
string_extensions.enableStringExtensions();
|
382
|
+
return number_extensions.enableNumberExtensions();
|
383
|
+
};
|
384
|
+
|
385
|
+
require('./default_inflections');
|
386
|
+
|
387
|
+
}).call(this);
|
388
|
+
|
389
|
+
});
|
390
|
+
|
391
|
+
require.define("/inflect/version.coffee", function (require, module, exports, __dirname, __filename) {
|
392
|
+
(function() {
|
393
|
+
var data, path;
|
394
|
+
|
395
|
+
path = require('path');
|
396
|
+
|
397
|
+
if (process.title === 'browser') {
|
398
|
+
data = require('files')['package.json'];
|
399
|
+
} else {
|
400
|
+
data = require('fs').readFileSync(path.join(__dirname, '/../../package.json'));
|
401
|
+
}
|
402
|
+
|
403
|
+
exports.package = JSON.parse(data);
|
404
|
+
|
405
|
+
exports.version = exports.package.version;
|
406
|
+
|
407
|
+
}).call(this);
|
408
|
+
|
409
|
+
});
|
410
|
+
|
411
|
+
require.define("fs", function (require, module, exports, __dirname, __filename) {
|
412
|
+
// nothing to see here... no file methods for the browser
|
413
|
+
|
414
|
+
});
|
415
|
+
|
416
|
+
require.define("/inflect/inflections.coffee", function (require, module, exports, __dirname, __filename) {
|
417
|
+
(function() {
|
418
|
+
var Inflections;
|
419
|
+
var __slice = Array.prototype.slice;
|
420
|
+
|
421
|
+
Inflections = (function() {
|
422
|
+
|
423
|
+
Inflections.instance = function() {
|
424
|
+
return this.__instance__ || (this.__instance__ = new this);
|
425
|
+
};
|
426
|
+
|
427
|
+
function Inflections() {
|
428
|
+
this.plurals = [];
|
429
|
+
this.singulars = [];
|
430
|
+
this.uncountables = [];
|
431
|
+
this.humans = [];
|
432
|
+
}
|
433
|
+
|
434
|
+
Inflections.prototype.plural = function(rule, replacement) {
|
435
|
+
var index;
|
436
|
+
if (typeof rule === 'string' && (index = this.uncountables.indexOf(rule)) !== -1) {
|
437
|
+
this.uncountables.splice(index, 1);
|
438
|
+
}
|
439
|
+
if ((index = this.uncountables.indexOf(replacement)) !== -1) {
|
440
|
+
this.uncountables.splice(index, 1);
|
441
|
+
}
|
442
|
+
return this.plurals.unshift([rule, replacement]);
|
443
|
+
};
|
444
|
+
|
445
|
+
Inflections.prototype.singular = function(rule, replacement) {
|
446
|
+
var index;
|
447
|
+
if (typeof rule === 'string' && (index = this.uncountables.indexOf(rule)) !== -1) {
|
448
|
+
this.uncountables.splice(index, 1);
|
449
|
+
}
|
450
|
+
if ((index = this.uncountables.indexOf(replacement)) !== -1) {
|
451
|
+
this.uncountables.splice(index, 1);
|
452
|
+
}
|
453
|
+
return this.singulars.unshift([rule, replacement]);
|
454
|
+
};
|
455
|
+
|
456
|
+
Inflections.prototype.irregular = function(singular, plural) {
|
457
|
+
var index;
|
458
|
+
if ((index = this.uncountables.indexOf(singular)) !== -1) {
|
459
|
+
this.uncountables.splice(index, 1);
|
460
|
+
}
|
461
|
+
if ((index = this.uncountables.indexOf(plural)) !== -1) {
|
462
|
+
this.uncountables.splice(index, 1);
|
463
|
+
}
|
464
|
+
if (singular[0].toUpperCase() === plural[0].toUpperCase()) {
|
465
|
+
this.plural(new RegExp("(" + singular[0] + ")" + singular.slice(1) + "$", "i"), '$1' + plural.slice(1));
|
466
|
+
this.plural(new RegExp("(" + plural[0] + ")" + plural.slice(1) + "$", "i"), '$1' + plural.slice(1));
|
467
|
+
return this.singular(new RegExp("(" + plural[0] + ")" + plural.slice(1) + "$", "i"), '$1' + singular.slice(1));
|
468
|
+
} else {
|
469
|
+
this.plural(new RegExp("" + (singular[0].toUpperCase()) + singular.slice(1) + "$"), plural[0].toUpperCase() + plural.slice(1));
|
470
|
+
this.plural(new RegExp("" + (singular[0].toLowerCase()) + singular.slice(1) + "$"), plural[0].toLowerCase() + plural.slice(1));
|
471
|
+
this.plural(new RegExp("" + (plural[0].toUpperCase()) + plural.slice(1) + "$"), plural[0].toUpperCase() + plural.slice(1));
|
472
|
+
this.plural(new RegExp("" + (plural[0].toLowerCase()) + plural.slice(1) + "$"), plural[0].toLowerCase() + plural.slice(1));
|
473
|
+
this.singular(new RegExp("" + (plural[0].toUpperCase()) + plural.slice(1) + "$"), singular[0].toUpperCase() + singular.slice(1));
|
474
|
+
return this.singular(new RegExp("" + (plural[0].toLowerCase()) + plural.slice(1) + "$"), singular[0].toLowerCase() + singular.slice(1));
|
475
|
+
}
|
476
|
+
};
|
477
|
+
|
478
|
+
Inflections.prototype.uncountable = function() {
|
479
|
+
var words;
|
480
|
+
words = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
|
481
|
+
return this.uncountables = this.uncountables.concat(words);
|
482
|
+
};
|
483
|
+
|
484
|
+
Inflections.prototype.human = function(rule, replacement) {
|
485
|
+
return this.humans.unshift([rule, replacement]);
|
486
|
+
};
|
487
|
+
|
488
|
+
Inflections.prototype.clear = function(scope) {
|
489
|
+
if (scope == null) scope = 'all';
|
490
|
+
if (scope === 'all') {
|
491
|
+
this.plurals = [];
|
492
|
+
this.singulars = [];
|
493
|
+
this.uncountables = [];
|
494
|
+
return this.humans = [];
|
495
|
+
} else {
|
496
|
+
return this[scope] = [];
|
497
|
+
}
|
498
|
+
};
|
499
|
+
|
500
|
+
return Inflections;
|
501
|
+
|
502
|
+
})();
|
503
|
+
|
504
|
+
exports.Inflections = Inflections;
|
505
|
+
|
506
|
+
}).call(this);
|
507
|
+
|
508
|
+
});
|
509
|
+
|
510
|
+
require.define("/inflect/methods.coffee", function (require, module, exports, __dirname, __filename) {
|
511
|
+
(function() {
|
512
|
+
var camelize, capitalize, dasherize, humanize, inflections, ordinalize, parameterize, pluralize, singularize, titleize, underscore;
|
513
|
+
|
514
|
+
inflections = require('../inflect').inflections;
|
515
|
+
|
516
|
+
camelize = function(lower_case_and_underscored_word, first_letter_in_uppercase) {
|
517
|
+
var rest;
|
518
|
+
if (first_letter_in_uppercase == null) first_letter_in_uppercase = true;
|
519
|
+
rest = lower_case_and_underscored_word.replace(/_./g, function(val) {
|
520
|
+
return val.slice(1).toUpperCase();
|
521
|
+
});
|
522
|
+
if (first_letter_in_uppercase) {
|
523
|
+
return lower_case_and_underscored_word[0].toUpperCase() + rest.slice(1);
|
524
|
+
} else {
|
525
|
+
return lower_case_and_underscored_word[0].toLowerCase() + rest.slice(1);
|
526
|
+
}
|
527
|
+
};
|
528
|
+
|
529
|
+
underscore = function(camel_cased_word) {
|
530
|
+
var word;
|
531
|
+
word = camel_cased_word.toString();
|
532
|
+
word = word.replace(/([A-Z]+)([A-Z][a-z])/g, '$1_$2');
|
533
|
+
word = word.replace(/([a-z\d])([A-Z])/g, '$1_$2');
|
534
|
+
word = word.replace(/-/g, '_');
|
535
|
+
word = word.toLowerCase();
|
536
|
+
return word;
|
537
|
+
};
|
538
|
+
|
539
|
+
dasherize = function(underscored_word) {
|
540
|
+
return underscored_word.replace(/_/g, '-');
|
541
|
+
};
|
542
|
+
|
543
|
+
titleize = function(word) {
|
544
|
+
return humanize(underscore(word)).replace(/\b('?[a-z])/g, function(val) {
|
545
|
+
return capitalize(val);
|
546
|
+
});
|
547
|
+
};
|
548
|
+
|
549
|
+
capitalize = function(word) {
|
550
|
+
return (word[0] || '').toUpperCase() + (word.slice(1) || '').toLowerCase();
|
551
|
+
};
|
552
|
+
|
553
|
+
pluralize = function(word) {
|
554
|
+
var plural, replacement, result, rule, _i, _len, _ref;
|
555
|
+
result = word.toString();
|
556
|
+
if (word.length === 0 || inflections().uncountables.indexOf(result.toLowerCase()) !== -1) {
|
557
|
+
return result;
|
558
|
+
} else {
|
559
|
+
_ref = inflections().plurals;
|
560
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
561
|
+
plural = _ref[_i];
|
562
|
+
rule = plural[0];
|
563
|
+
replacement = plural[1];
|
564
|
+
if (result.search(rule) !== -1) {
|
565
|
+
result = result.replace(rule, replacement);
|
566
|
+
break;
|
567
|
+
}
|
568
|
+
}
|
569
|
+
return result;
|
570
|
+
}
|
571
|
+
};
|
572
|
+
|
573
|
+
singularize = function(word) {
|
574
|
+
var inflection, replacement, result, rule, singular, uncountable, _i, _j, _len, _len2, _ref, _ref2;
|
575
|
+
result = word.toString();
|
576
|
+
uncountable = false;
|
577
|
+
_ref = inflections().uncountables;
|
578
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
579
|
+
inflection = _ref[_i];
|
580
|
+
if (result.search(new RegExp("\\b" + inflection + "$", 'i')) !== -1) {
|
581
|
+
uncountable = true;
|
582
|
+
break;
|
583
|
+
}
|
584
|
+
}
|
585
|
+
if (word.length === 0 || uncountable) {
|
586
|
+
return result;
|
587
|
+
} else {
|
588
|
+
_ref2 = inflections().singulars;
|
589
|
+
for (_j = 0, _len2 = _ref2.length; _j < _len2; _j++) {
|
590
|
+
singular = _ref2[_j];
|
591
|
+
rule = singular[0];
|
592
|
+
replacement = singular[1];
|
593
|
+
if (result.search(rule) !== -1) {
|
594
|
+
result = result.replace(rule, replacement);
|
595
|
+
break;
|
596
|
+
}
|
597
|
+
}
|
598
|
+
return result;
|
599
|
+
}
|
600
|
+
};
|
601
|
+
|
602
|
+
humanize = function(lower_case_and_underscored_word) {
|
603
|
+
var human, replacement, result, rule, _i, _len, _ref;
|
604
|
+
result = lower_case_and_underscored_word.toString();
|
605
|
+
_ref = inflections().humans;
|
606
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
607
|
+
human = _ref[_i];
|
608
|
+
rule = human[0];
|
609
|
+
replacement = human[1];
|
610
|
+
if (result.search(rule) !== -1) {
|
611
|
+
result = result.replace(rule, replacement);
|
612
|
+
break;
|
613
|
+
}
|
614
|
+
}
|
615
|
+
return capitalize(result.replace(/_id$/, '').replace(/_/g, ' '));
|
616
|
+
};
|
617
|
+
|
618
|
+
ordinalize = function(number) {
|
619
|
+
var number_int;
|
620
|
+
number_int = parseInt(number, 10);
|
621
|
+
if ([11, 12, 13].indexOf(number_int % 100) !== -1) {
|
622
|
+
return "" + number + "th";
|
623
|
+
} else {
|
624
|
+
switch (number_int % 10) {
|
625
|
+
case 1:
|
626
|
+
return "" + number + "st";
|
627
|
+
case 2:
|
628
|
+
return "" + number + "nd";
|
629
|
+
case 3:
|
630
|
+
return "" + number + "rd";
|
631
|
+
default:
|
632
|
+
return "" + number + "th";
|
633
|
+
}
|
634
|
+
}
|
635
|
+
};
|
636
|
+
|
637
|
+
parameterize = function(string, sep) {
|
638
|
+
var parameterized_string;
|
639
|
+
if (sep == null) sep = '-';
|
640
|
+
parameterized_string = string.toString();
|
641
|
+
parameterized_string = parameterized_string.replace(/[^a-z0-9\-_]+/gi, sep);
|
642
|
+
if (sep != null) {
|
643
|
+
parameterized_string = parameterized_string.replace(new RegExp("" + sep + "{2,}", 'g'), sep);
|
644
|
+
parameterized_string = parameterized_string.replace(new RegExp("^" + sep + "|" + sep + "$", 'gi'), '');
|
645
|
+
}
|
646
|
+
return parameterized_string.toLowerCase();
|
647
|
+
};
|
648
|
+
|
649
|
+
exports.camelize = camelize;
|
650
|
+
|
651
|
+
exports.underscore = underscore;
|
652
|
+
|
653
|
+
exports.dasherize = dasherize;
|
654
|
+
|
655
|
+
exports.titleize = titleize;
|
656
|
+
|
657
|
+
exports.capitalize = capitalize;
|
658
|
+
|
659
|
+
exports.pluralize = pluralize;
|
660
|
+
|
661
|
+
exports.singularize = singularize;
|
662
|
+
|
663
|
+
exports.humanize = humanize;
|
664
|
+
|
665
|
+
exports.ordinalize = ordinalize;
|
666
|
+
|
667
|
+
exports.parameterize = parameterize;
|
668
|
+
|
669
|
+
}).call(this);
|
670
|
+
|
671
|
+
});
|
672
|
+
|
673
|
+
require.define("/inflect/string_extensions.coffee", function (require, module, exports, __dirname, __filename) {
|
674
|
+
(function() {
|
675
|
+
var enableStringExtensions, inflect;
|
676
|
+
|
677
|
+
inflect = require('../inflect');
|
678
|
+
|
679
|
+
enableStringExtensions = function() {
|
680
|
+
String.prototype.pluralize = function() {
|
681
|
+
return inflect.pluralize(this);
|
682
|
+
};
|
683
|
+
String.prototype.singularize = function() {
|
684
|
+
return inflect.singularize(this);
|
685
|
+
};
|
686
|
+
String.prototype.camelize = function(first_letter_in_uppercase) {
|
687
|
+
if (first_letter_in_uppercase == null) first_letter_in_uppercase = true;
|
688
|
+
return inflect.camelize(this, first_letter_in_uppercase);
|
689
|
+
};
|
690
|
+
String.prototype.capitalize = function() {
|
691
|
+
return inflect.capitalize(this);
|
692
|
+
};
|
693
|
+
String.prototype.titleize = function() {
|
694
|
+
return inflect.titleize(this);
|
695
|
+
};
|
696
|
+
String.prototype.underscore = function() {
|
697
|
+
return inflect.underscore(this);
|
698
|
+
};
|
699
|
+
String.prototype.dasherize = function() {
|
700
|
+
return inflect.dasherize(this);
|
701
|
+
};
|
702
|
+
String.prototype.parameterize = function(sep) {
|
703
|
+
if (sep == null) sep = '-';
|
704
|
+
return inflect.parameterize(this, sep);
|
705
|
+
};
|
706
|
+
return String.prototype.humanize = function() {
|
707
|
+
return inflect.humanize(this);
|
708
|
+
};
|
709
|
+
};
|
710
|
+
|
711
|
+
exports.enableStringExtensions = enableStringExtensions;
|
712
|
+
|
713
|
+
}).call(this);
|
714
|
+
|
715
|
+
});
|
716
|
+
|
717
|
+
require.define("/inflect/number_extensions.coffee", function (require, module, exports, __dirname, __filename) {
|
718
|
+
(function() {
|
719
|
+
var enableNumberExtensions, inflect;
|
720
|
+
|
721
|
+
inflect = require('../inflect');
|
722
|
+
|
723
|
+
enableNumberExtensions = function() {
|
724
|
+
return Number.prototype.ordinalize = function() {
|
725
|
+
return inflect.ordinalize(this);
|
726
|
+
};
|
727
|
+
};
|
728
|
+
|
729
|
+
exports.enableNumberExtensions = enableNumberExtensions;
|
730
|
+
|
731
|
+
}).call(this);
|
732
|
+
|
733
|
+
});
|
734
|
+
|
735
|
+
require.define("/inflect/default_inflections.coffee", function (require, module, exports, __dirname, __filename) {
|
736
|
+
(function() {
|
737
|
+
var inflect;
|
738
|
+
|
739
|
+
inflect = require('../inflect');
|
740
|
+
|
741
|
+
inflect.inflections(function(inflect) {
|
742
|
+
inflect.plural(/$/, 's');
|
743
|
+
inflect.plural(/s$/i, 's');
|
744
|
+
inflect.plural(/(ax|test)is$/i, '$1es');
|
745
|
+
inflect.plural(/(octop|vir)us$/i, '$1i');
|
746
|
+
inflect.plural(/(octop|vir)i$/i, '$1i');
|
747
|
+
inflect.plural(/(alias|status)$/i, '$1es');
|
748
|
+
inflect.plural(/(bu)s$/i, '$1ses');
|
749
|
+
inflect.plural(/(buffal|tomat)o$/i, '$1oes');
|
750
|
+
inflect.plural(/([ti])um$/i, '$1a');
|
751
|
+
inflect.plural(/([ti])a$/i, '$1a');
|
752
|
+
inflect.plural(/sis$/i, 'ses');
|
753
|
+
inflect.plural(/(?:([^f])fe|([lr])f)$/i, '$1$2ves');
|
754
|
+
inflect.plural(/(hive)$/i, '$1s');
|
755
|
+
inflect.plural(/([^aeiouy]|qu)y$/i, '$1ies');
|
756
|
+
inflect.plural(/(x|ch|ss|sh)$/i, '$1es');
|
757
|
+
inflect.plural(/(matr|vert|ind)(?:ix|ex)$/i, '$1ices');
|
758
|
+
inflect.plural(/([m|l])ouse$/i, '$1ice');
|
759
|
+
inflect.plural(/([m|l])ice$/i, '$1ice');
|
760
|
+
inflect.plural(/^(ox)$/i, '$1en');
|
761
|
+
inflect.plural(/^(oxen)$/i, '$1');
|
762
|
+
inflect.plural(/(quiz)$/i, '$1zes');
|
763
|
+
inflect.singular(/s$/i, '');
|
764
|
+
inflect.singular(/(n)ews$/i, '$1ews');
|
765
|
+
inflect.singular(/([ti])a$/i, '$1um');
|
766
|
+
inflect.singular(/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i, '$1$2sis');
|
767
|
+
inflect.singular(/(^analy)ses$/i, '$1sis');
|
768
|
+
inflect.singular(/([^f])ves$/i, '$1fe');
|
769
|
+
inflect.singular(/(hive)s$/i, '$1');
|
770
|
+
inflect.singular(/(tive)s$/i, '$1');
|
771
|
+
inflect.singular(/([lr])ves$/i, '$1f');
|
772
|
+
inflect.singular(/([^aeiouy]|qu)ies$/i, '$1y');
|
773
|
+
inflect.singular(/(s)eries$/i, '$1eries');
|
774
|
+
inflect.singular(/(m)ovies$/i, '$1ovie');
|
775
|
+
inflect.singular(/(x|ch|ss|sh)es$/i, '$1');
|
776
|
+
inflect.singular(/([m|l])ice$/i, '$1ouse');
|
777
|
+
inflect.singular(/(bus)es$/i, '$1');
|
778
|
+
inflect.singular(/(o)es$/i, '$1');
|
779
|
+
inflect.singular(/(shoe)s$/i, '$1');
|
780
|
+
inflect.singular(/(cris|ax|test)es$/i, '$1is');
|
781
|
+
inflect.singular(/(octop|vir)i$/i, '$1us');
|
782
|
+
inflect.singular(/(alias|status)es$/i, '$1');
|
783
|
+
inflect.singular(/^(ox)en/i, '$1');
|
784
|
+
inflect.singular(/(vert|ind)ices$/i, '$1ex');
|
785
|
+
inflect.singular(/(matr)ices$/i, '$1ix');
|
786
|
+
inflect.singular(/(quiz)zes$/i, '$1');
|
787
|
+
inflect.singular(/(database)s$/i, '$1');
|
788
|
+
inflect.irregular('person', 'people');
|
789
|
+
inflect.irregular('man', 'men');
|
790
|
+
inflect.irregular('child', 'children');
|
791
|
+
inflect.irregular('move', 'moves');
|
792
|
+
inflect.irregular('she', 'they');
|
793
|
+
inflect.irregular('he', 'they');
|
794
|
+
inflect.irregular('myself', 'ourselves');
|
795
|
+
inflect.irregular('yourself', 'ourselves');
|
796
|
+
inflect.irregular('himself', 'themselves');
|
797
|
+
inflect.irregular('herself', 'themselves');
|
798
|
+
inflect.irregular('themself', 'themselves');
|
799
|
+
inflect.irregular('mine', 'ours');
|
800
|
+
inflect.irregular('hers', 'theirs');
|
801
|
+
inflect.irregular('his', 'theirs');
|
802
|
+
inflect.irregular('its', 'theirs');
|
803
|
+
inflect.irregular('theirs', 'theirs');
|
804
|
+
inflect.irregular('sex', 'sexes');
|
805
|
+
inflect.irregular('cow', 'kine');
|
806
|
+
inflect.irregular('zombie', 'zombies');
|
807
|
+
inflect.uncountable('advice', 'energy', 'excretion', 'digestion', 'cooperation', 'health', 'justice', 'jeans');
|
808
|
+
inflect.uncountable('labour', 'machinery', 'equipment', 'information', 'pollution', 'sewage', 'paper', 'money');
|
809
|
+
inflect.uncountable('species', 'series', 'rain', 'rice', 'fish', 'sheep', 'moose', 'deer', 'bison', 'proceedings');
|
810
|
+
inflect.uncountable('shears', 'pincers', 'breeches', 'hijinks', 'clippers', 'chassis', 'innings', 'elk');
|
811
|
+
return inflect.uncountable('rhinoceros', 'swine', 'you', 'news');
|
812
|
+
});
|
813
|
+
|
814
|
+
}).call(this);
|
815
|
+
|
816
|
+
});
|
817
|
+
|
818
|
+
require.define("/index.coffee", function (require, module, exports, __dirname, __filename) {
|
819
|
+
|
820
|
+
module.exports = require("./inflect");
|
821
|
+
|
822
|
+
});
|
823
|
+
require("/index.coffee");
|
824
|
+
|
825
|
+
window.inflect = require('./inflect');
|