js_stack 1.11.1 → 1.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e18613e1a854b61cd62ab38af1097a1e698e6ce2
|
4
|
+
data.tar.gz: 9fbe7406315e3a6111e522eb7a546be7c8223830
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 05cab61f037677653bec5069d45dbe086887e5d2b66b48d27e6319081fd5cd4f5cb4d212f21349529908d13c61ccc7c8e03973f2da0ba75f19cb49a3b11eef70
|
7
|
+
data.tar.gz: fdf05134893a57f6efc7fa9be95ee8602af045b6ae41bd3b68383332508f47817fe230a5890c631e3e30ddd8b262f4fa4d09bdc1f0ab6676bccd70b9268b127e
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -68,7 +68,7 @@ Examples:
|
|
68
68
|
| backbone virtualcollection | **0.6.6**, 0.5.3, 0.4.15 | [changelog](https://github.com/p3drosola/Backbone.VirtualCollection/wiki/Changelog) | [homepage](https://github.com/p3drosola/Backbone.VirtualCollection) |
|
69
69
|
| cocktail | **0.5.10** | None | [homepage](https://github.com/onsi/cocktail) |
|
70
70
|
| momentjs | **2.10.6** | [changelog](https://github.com/moment/moment/blob/develop/CHANGELOG.md) | [homepage](https://github.com/moment/moment) |
|
71
|
-
| underscore inflections | **0.2.1
|
71
|
+
| underscore inflections | **1.3.0**, 0.2.1 | None | [homepage](https://github.com/jeremyruppel/underscore.inflection) [homepage 0.2.1](https://github.com/geetarista/underscore.inflections) |
|
72
72
|
| underscore string | **3.2.2**, 3.0.3, 2.4.0, 2.3.2 | [changelog](https://github.com/epeli/underscore.string/blob/master/CHANGELOG.markdown) | [homepage](http://epeli.github.io/underscore.string/) |
|
73
73
|
|
74
74
|
## Contributing
|
data/lib/js_stack/version.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
//= require js_stack/plugins/underscore/inflections/
|
1
|
+
//= require js_stack/plugins/underscore/inflections/1.3.0
|
@@ -0,0 +1,255 @@
|
|
1
|
+
// Underscore.inflection.js
|
2
|
+
// (c) 2014 Jeremy Ruppel
|
3
|
+
// Underscore.inflection is freely distributable under the MIT license.
|
4
|
+
// Portions of Underscore.inflection are inspired or borrowed from ActiveSupport
|
5
|
+
// Version 1.0.0
|
6
|
+
|
7
|
+
(function(root, factory) {
|
8
|
+
if (typeof define === 'function' && define.amd) {
|
9
|
+
// AMD. Register as an anonymous module.
|
10
|
+
define(['underscore'], factory);
|
11
|
+
} else if (typeof require === 'function' && typeof exports === 'object') {
|
12
|
+
// CommonJS
|
13
|
+
module.exports = factory(require('underscore'));
|
14
|
+
} else {
|
15
|
+
// Browser globals (root is window)
|
16
|
+
factory(root._);
|
17
|
+
}
|
18
|
+
})(this, function(_, undefined) {
|
19
|
+
var plurals = [];
|
20
|
+
var singulars = [];
|
21
|
+
var uncountables = [];
|
22
|
+
|
23
|
+
/**
|
24
|
+
* Inflector
|
25
|
+
*/
|
26
|
+
var inflector = {
|
27
|
+
|
28
|
+
/**
|
29
|
+
* `gsub` is a method that is just slightly different than our
|
30
|
+
* standard `String#replace`. The main differences are that it
|
31
|
+
* matches globally every time, and if no substitution is made
|
32
|
+
* it returns `null`. It accepts a string for `word` and
|
33
|
+
* `replacement`, and `rule` can be either a string or a regex.
|
34
|
+
*/
|
35
|
+
gsub: function(word, rule, replacement) {
|
36
|
+
var pattern = new RegExp(rule.source || rule, 'gi');
|
37
|
+
|
38
|
+
return pattern.test(word) ? word.replace(pattern, replacement) : null;
|
39
|
+
},
|
40
|
+
|
41
|
+
/**
|
42
|
+
* `plural` creates a new pluralization rule for the inflector.
|
43
|
+
* `rule` can be either a string or a regex.
|
44
|
+
*/
|
45
|
+
plural: function(rule, replacement) {
|
46
|
+
plurals.unshift([rule, replacement]);
|
47
|
+
},
|
48
|
+
|
49
|
+
/**
|
50
|
+
* Pluralizes the string passed to it. It also can accept a
|
51
|
+
* number as the second parameter. If a number is provided,
|
52
|
+
* it will pluralize the word to match the number. Optionally,
|
53
|
+
* you can pass `true` as a third parameter. If found, this
|
54
|
+
* will include the count with the output.
|
55
|
+
*/
|
56
|
+
pluralize: function(word, count, includeNumber) {
|
57
|
+
var result;
|
58
|
+
|
59
|
+
if (count !== undefined) {
|
60
|
+
count = parseFloat(count);
|
61
|
+
result = (count === 1) ? this.singularize(word) : this.pluralize(word);
|
62
|
+
result = (includeNumber) ? [count, result].join(' ') : result;
|
63
|
+
} else {
|
64
|
+
if (_(uncountables).include(word)) {
|
65
|
+
return word;
|
66
|
+
}
|
67
|
+
|
68
|
+
result = word;
|
69
|
+
|
70
|
+
_(plurals).detect(function(rule) {
|
71
|
+
var gsub = this.gsub(word, rule[0], rule[1]);
|
72
|
+
|
73
|
+
return gsub ? (result = gsub) : false;
|
74
|
+
},
|
75
|
+
this);
|
76
|
+
}
|
77
|
+
|
78
|
+
return result;
|
79
|
+
},
|
80
|
+
|
81
|
+
/**
|
82
|
+
* `singular` creates a new singularization rule for the
|
83
|
+
* inflector. `rule` can be either a string or a regex.
|
84
|
+
*/
|
85
|
+
singular: function(rule, replacement) {
|
86
|
+
singulars.unshift([rule, replacement]);
|
87
|
+
},
|
88
|
+
|
89
|
+
/**
|
90
|
+
* `singularize` returns the singular version of the plural
|
91
|
+
* passed to it.
|
92
|
+
*/
|
93
|
+
singularize: function(word) {
|
94
|
+
if (_(uncountables).include(word)) {
|
95
|
+
return word;
|
96
|
+
}
|
97
|
+
|
98
|
+
var result = word;
|
99
|
+
|
100
|
+
_(singulars).detect(function(rule) {
|
101
|
+
var gsub = this.gsub(word, rule[0], rule[1]);
|
102
|
+
|
103
|
+
return gsub ? (result = gsub) : false;
|
104
|
+
},
|
105
|
+
this);
|
106
|
+
|
107
|
+
return result;
|
108
|
+
},
|
109
|
+
|
110
|
+
/**
|
111
|
+
* `irregular` is a shortcut method to create both a
|
112
|
+
* pluralization and singularization rule for the word at
|
113
|
+
* the same time. You must supply both the singular form
|
114
|
+
* and the plural form as explicit strings.
|
115
|
+
*/
|
116
|
+
irregular: function(singular, plural) {
|
117
|
+
this.plural('\\b' + singular + '\\b', plural);
|
118
|
+
this.singular('\\b' + plural + '\\b', singular);
|
119
|
+
},
|
120
|
+
|
121
|
+
/**
|
122
|
+
* `uncountable` creates a new uncountable rule for `word`.
|
123
|
+
* Uncountable words do not get pluralized or singularized.
|
124
|
+
*/
|
125
|
+
uncountable: function(word) {
|
126
|
+
uncountables.unshift(word);
|
127
|
+
},
|
128
|
+
|
129
|
+
/**
|
130
|
+
* `ordinalize` adds an ordinal suffix to `number`.
|
131
|
+
*/
|
132
|
+
ordinalize: function(number) {
|
133
|
+
if (isNaN(number)) {
|
134
|
+
return number;
|
135
|
+
}
|
136
|
+
|
137
|
+
number = number.toString();
|
138
|
+
var lastDigit = number.slice(-1);
|
139
|
+
var lastTwoDigits = number.slice(-2);
|
140
|
+
|
141
|
+
if (lastTwoDigits === '11' || lastTwoDigits === '12' || lastTwoDigits === '13') {
|
142
|
+
return number + 'th';
|
143
|
+
}
|
144
|
+
|
145
|
+
switch (lastDigit) {
|
146
|
+
case '1':
|
147
|
+
return number + 'st';
|
148
|
+
case '2':
|
149
|
+
return number + 'nd';
|
150
|
+
case '3':
|
151
|
+
return number + 'rd';
|
152
|
+
default:
|
153
|
+
return number + 'th';
|
154
|
+
}
|
155
|
+
},
|
156
|
+
|
157
|
+
/**
|
158
|
+
* `titleize` capitalizes the first letter of each word in
|
159
|
+
* the string `words`. It preserves the existing whitespace.
|
160
|
+
*/
|
161
|
+
titleize: function(words) {
|
162
|
+
if (typeof words !== 'string') {
|
163
|
+
return words;
|
164
|
+
}
|
165
|
+
|
166
|
+
return words.replace(/\S+/g, function(word) {
|
167
|
+
return word.charAt(0).toUpperCase() + word.slice(1);
|
168
|
+
});
|
169
|
+
},
|
170
|
+
|
171
|
+
/**
|
172
|
+
* Resets the inflector's rules to their initial state,
|
173
|
+
* clearing out any custom rules that have been added.
|
174
|
+
*/
|
175
|
+
resetInflections: function() {
|
176
|
+
plurals = [];
|
177
|
+
singulars = [];
|
178
|
+
uncountables = [];
|
179
|
+
|
180
|
+
this.plural(/$/, 's');
|
181
|
+
this.plural(/s$/, 's');
|
182
|
+
this.plural(/(ax|test)is$/, '$1es');
|
183
|
+
this.plural(/(octop|vir)us$/, '$1i');
|
184
|
+
this.plural(/(octop|vir)i$/, '$1i');
|
185
|
+
this.plural(/(alias|status)$/, '$1es');
|
186
|
+
this.plural(/(bu)s$/, '$1ses');
|
187
|
+
this.plural(/(buffal|tomat)o$/, '$1oes');
|
188
|
+
this.plural(/([ti])um$/, '$1a');
|
189
|
+
this.plural(/([ti])a$/, '$1a');
|
190
|
+
this.plural(/sis$/, 'ses');
|
191
|
+
this.plural(/(?:([^f])fe|([lr])?f)$/, '$1$2ves');
|
192
|
+
this.plural(/(hive)$/, '$1s');
|
193
|
+
this.plural(/([^aeiouy]|qu)y$/, '$1ies');
|
194
|
+
this.plural(/(x|ch|ss|sh)$/, '$1es');
|
195
|
+
this.plural(/(matr|vert|ind)(?:ix|ex)$/, '$1ices');
|
196
|
+
this.plural(/([m|l])ouse$/, '$1ice');
|
197
|
+
this.plural(/([m|l])ice$/, '$1ice');
|
198
|
+
this.plural(/^(ox)$/, '$1en');
|
199
|
+
this.plural(/^(oxen)$/, '$1');
|
200
|
+
this.plural(/(quiz)$/, '$1zes');
|
201
|
+
|
202
|
+
this.singular(/s$/, '');
|
203
|
+
this.singular(/(n)ews$/, '$1ews');
|
204
|
+
this.singular(/([ti])a$/, '$1um');
|
205
|
+
this.singular(/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/, '$1$2sis');
|
206
|
+
this.singular(/(^analy)ses$/, '$1sis');
|
207
|
+
this.singular(/([^f])ves$/, '$1fe');
|
208
|
+
this.singular(/(hive)s$/, '$1');
|
209
|
+
this.singular(/(tive)s$/, '$1');
|
210
|
+
this.singular(/([lr])ves$/, '$1f');
|
211
|
+
this.singular(/([^aeiouy]|qu)ies$/, '$1y');
|
212
|
+
this.singular(/(s)eries$/, '$1eries');
|
213
|
+
this.singular(/(m)ovies$/, '$1ovie');
|
214
|
+
this.singular(/(x|ch|ss|sh)es$/, '$1');
|
215
|
+
this.singular(/([m|l])ice$/, '$1ouse');
|
216
|
+
this.singular(/(bus)es$/, '$1');
|
217
|
+
this.singular(/(o)es$/, '$1');
|
218
|
+
this.singular(/(shoe)s$/, '$1');
|
219
|
+
this.singular(/(cris|ax|test)es$/, '$1is');
|
220
|
+
this.singular(/(octop|vir)i$/, '$1us');
|
221
|
+
this.singular(/(alias|status)es$/, '$1');
|
222
|
+
this.singular(/^(ox)en/, '$1');
|
223
|
+
this.singular(/(vert|ind)ices$/, '$1ex');
|
224
|
+
this.singular(/(matr)ices$/, '$1ix');
|
225
|
+
this.singular(/(quiz)zes$/, '$1');
|
226
|
+
this.singular(/(database)s$/, '$1');
|
227
|
+
|
228
|
+
this.irregular('person', 'people');
|
229
|
+
this.irregular('man', 'men');
|
230
|
+
this.irregular('child', 'children');
|
231
|
+
this.irregular('sex', 'sexes');
|
232
|
+
this.irregular('move', 'moves');
|
233
|
+
this.irregular('cow', 'kine');
|
234
|
+
|
235
|
+
this.uncountable('equipment');
|
236
|
+
this.uncountable('information');
|
237
|
+
this.uncountable('rice');
|
238
|
+
this.uncountable('money');
|
239
|
+
this.uncountable('species');
|
240
|
+
this.uncountable('series');
|
241
|
+
this.uncountable('fish');
|
242
|
+
this.uncountable('sheep');
|
243
|
+
this.uncountable('jeans');
|
244
|
+
|
245
|
+
return this;
|
246
|
+
}
|
247
|
+
};
|
248
|
+
|
249
|
+
/**
|
250
|
+
* Underscore integration
|
251
|
+
*/
|
252
|
+
_.mixin(inflector.resetInflections());
|
253
|
+
|
254
|
+
return inflector;
|
255
|
+
});
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: js_stack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomasz Pewiński
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-10-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: haml_coffee_assets
|
@@ -228,6 +228,7 @@ files:
|
|
228
228
|
- vendor/assets/javascripts/js_stack/plugins/underscore.inflections.js
|
229
229
|
- vendor/assets/javascripts/js_stack/plugins/underscore.string.js
|
230
230
|
- vendor/assets/javascripts/js_stack/plugins/underscore/inflections/0.2.1.js
|
231
|
+
- vendor/assets/javascripts/js_stack/plugins/underscore/inflections/1.3.0.js
|
231
232
|
- vendor/assets/javascripts/js_stack/plugins/underscore/string/2.3.2.js
|
232
233
|
- vendor/assets/javascripts/js_stack/plugins/underscore/string/2.4.0.js
|
233
234
|
- vendor/assets/javascripts/js_stack/plugins/underscore/string/3.0.3.js
|