underscore_plus 0.9.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 +15 -0
- data/.gitignore +18 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +4 -0
- data/Rakefile +1 -0
- data/app/assets/javascripts/underscore_plus.js +458 -0
- data/lib/underscore_plus/version.rb +3 -0
- data/lib/underscore_plus.rb +8 -0
- data/underscore_plus.gemspec +24 -0
- metadata +110 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
N2Y0MDMzMGNlZGI5ZDNlNTMwNDkwOTg0ZGU4MWE1NzdjMDk1M2IxMw==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
MGZmM2Y1MTc1YzYyNjUxNmE1MmNhMjM1Yzc1NjdiZjMzYmJiZTEzYg==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
NzE4YTAyNjZjYWQzMTA3ZjY3ZDI1ZWNiNGM2YTZmZTg5Y2RiYTljYjMxN2Y1
|
10
|
+
YmExMGNmMWFhYmI3MmI5MGU2NjQ0MWYyNWI0NzMwNTQ4NDFmNjFkMmViMWQy
|
11
|
+
ZmQ2NWRjZmVjNTI0ZWFiZGY3NGIyZDUwNzdiNjE0ODBlNDQ2NGU=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
N2ZmYWYwNDJmODRhMjBkYmNkNmM4NTNjMmYxNDg1MDYwYjVkNGFmY2VlMzEz
|
14
|
+
ODkwMDgyMmI4MmIwNWQ3OTdhMTE4N2M5NDdiZTgxNTFlNmRmZmM4ZDk4ZjMw
|
15
|
+
MzRhZjFhYmNjYTBiNTFmNDA4M2FhM2RiNzk2MjRiYmNhYTYxZjI=
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Gary McGhee
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,458 @@
|
|
1
|
+
// underscore_plus.js
|
2
|
+
// (c) 2013 Gary McGhee, Buzzware Solutions
|
3
|
+
// https://github.com/buzzware/underscore_plus
|
4
|
+
// Underscore may be freely distributed under the MIT license.
|
5
|
+
|
6
|
+
(function() {
|
7
|
+
|
8
|
+
//BEGIN copied from underscore
|
9
|
+
var ArrayProto = Array.prototype, ObjProto = Object.prototype, FuncProto = Function.prototype;
|
10
|
+
// Create quick reference variables for speed access to core prototypes.
|
11
|
+
var slice = ArrayProto.slice;
|
12
|
+
//END copied from underscore
|
13
|
+
|
14
|
+
_.stringify = function(aObject) {
|
15
|
+
if (_.isString(aObject))
|
16
|
+
return aObject;
|
17
|
+
if (aObject===null || aObject===undefined)
|
18
|
+
return '';
|
19
|
+
if (aObject.toString)
|
20
|
+
return aObject.toString();
|
21
|
+
return '';
|
22
|
+
};
|
23
|
+
|
24
|
+
//var MAX_DUMP_DEPTH = 10;
|
25
|
+
//
|
26
|
+
// function dumpObj(obj, name, indent, depth) {
|
27
|
+
// if (depth > MAX_DUMP_DEPTH) {
|
28
|
+
// return indent + name + ": <Maximum Depth Reached>\n";
|
29
|
+
// }
|
30
|
+
// if (typeof obj == "object") {
|
31
|
+
// var child = null;
|
32
|
+
// var output = indent + name + "\n";
|
33
|
+
// indent += "\t";
|
34
|
+
// for (var item in obj)
|
35
|
+
// {
|
36
|
+
// try {
|
37
|
+
// child = obj[item];
|
38
|
+
// } catch (e) {
|
39
|
+
// child = "<Unable to Evaluate>";
|
40
|
+
// }
|
41
|
+
// if (typeof child == "object") {
|
42
|
+
// output += dumpObj(child, item, indent, depth + 1);
|
43
|
+
// } else {
|
44
|
+
// output += indent + item + ": " + child + "\n";
|
45
|
+
// }
|
46
|
+
// }
|
47
|
+
// return output;
|
48
|
+
// } else {
|
49
|
+
// return obj;
|
50
|
+
// }
|
51
|
+
// }
|
52
|
+
|
53
|
+
_.concat = function(aArray,aAnotherArray) {
|
54
|
+
var result = [];
|
55
|
+
result.push.apply(result, aArray);
|
56
|
+
result.push.apply(result, aAnotherArray);
|
57
|
+
return result;
|
58
|
+
};
|
59
|
+
|
60
|
+
_.nameValueString = function(aObject) {
|
61
|
+
return _.map(_.keys(aObject),function(k) { return k+'="'+_.stringify(aObject[k])+'"'}).join(' ');
|
62
|
+
};
|
63
|
+
|
64
|
+
_.classEnsure = function(aOrig,aNew) {
|
65
|
+
if (!aOrig)
|
66
|
+
return aNew;
|
67
|
+
if (!aNew)
|
68
|
+
return aOrig;
|
69
|
+
return _.union(aOrig.split(' '),aNew.split(' '));
|
70
|
+
};
|
71
|
+
|
72
|
+
_.getPath = function(aObject,aPath,aDefault) {
|
73
|
+
if ((typeof aObject)=='string') { // allow aObject to be left out and assume this
|
74
|
+
if (arguments.length==1) {
|
75
|
+
aPath = aObject;
|
76
|
+
aObject = window;
|
77
|
+
} else if (arguments.length==2) {
|
78
|
+
aDefault = aPath;
|
79
|
+
aPath = aObject;
|
80
|
+
aObject = window;
|
81
|
+
}
|
82
|
+
}
|
83
|
+
var nodes = aPath.split('.');
|
84
|
+
var curr = aObject;
|
85
|
+
for (var i=0;i<nodes.length;i++) {
|
86
|
+
var name = nodes[i];
|
87
|
+
if ((curr===undefined)||(curr===null))
|
88
|
+
return aDefault;
|
89
|
+
if ((name in curr) || curr[name]) {
|
90
|
+
var val = curr[name];
|
91
|
+
if ((typeof val)=='function')
|
92
|
+
curr = val.call(curr);
|
93
|
+
else
|
94
|
+
curr = val;
|
95
|
+
} else {
|
96
|
+
return aDefault; // name doesn't exist
|
97
|
+
}
|
98
|
+
}
|
99
|
+
return curr;
|
100
|
+
}
|
101
|
+
|
102
|
+
_.moveKeys = function(aDest,aSource,aKeys) {
|
103
|
+
if (!aSource)
|
104
|
+
return aDest;
|
105
|
+
if (!aKeys)
|
106
|
+
aKeys = _.keys(aSource);
|
107
|
+
for (var i=0;i<aKeys.length;i++) {
|
108
|
+
var k = aKeys[i];
|
109
|
+
if (!(k in aSource))
|
110
|
+
continue;
|
111
|
+
aDest[k] = aSource[k];
|
112
|
+
delete aSource[k];
|
113
|
+
}
|
114
|
+
return aDest;
|
115
|
+
};
|
116
|
+
|
117
|
+
_.removeKey = function(aObject,aKey) {
|
118
|
+
var result = aObject[aKey];
|
119
|
+
delete aObject[aKey];
|
120
|
+
return result;
|
121
|
+
};
|
122
|
+
|
123
|
+
// for Twitter Typeahead. See http://code.whatcould.com/2013/02/28/underscore-templates-with-twitter-typeahead.html
|
124
|
+
_.templateTypeaheadCompatible = {
|
125
|
+
compile: function(str) {
|
126
|
+
return new _.templateTypeaheadCompiled(str);
|
127
|
+
}
|
128
|
+
}
|
129
|
+
_.templateTypeaheadCompiled = (function() {
|
130
|
+
function templateTypeaheadCompiled(str) {
|
131
|
+
this.compiledTemplate = _.template(str);
|
132
|
+
}
|
133
|
+
|
134
|
+
templateTypeaheadCompiled.prototype.render = function(context) {
|
135
|
+
return this.compiledTemplate(context);
|
136
|
+
};
|
137
|
+
|
138
|
+
return templateTypeaheadCompiled;
|
139
|
+
})();
|
140
|
+
|
141
|
+
// // find all dynamic objects in an array that have matching values for the contents of aAndCriteria
|
142
|
+
// public static function ObjectArrayFind(aArray:Array, aAndCriteria:Object):Array {
|
143
|
+
// return aArray.filter(
|
144
|
+
// function(item:*, index:int, array:Array):Boolean {
|
145
|
+
// // for all items in aAndCriteria, aItem has matching values
|
146
|
+
// for (var i:String in aAndCriteria) {
|
147
|
+
// if (aAndCriteria[i] != item[i])
|
148
|
+
// return false;
|
149
|
+
// }
|
150
|
+
// return true;
|
151
|
+
// }
|
152
|
+
// );
|
153
|
+
// }
|
154
|
+
//
|
155
|
+
// // like ObjectArrayFind except only returns one object. Could be optimised to quit searching when one is found
|
156
|
+
// // adds listener and removes on first occurrence
|
157
|
+
// public static function ObjectArrayFindOne(aArray:Array, aAndCriteria:Object):Object {
|
158
|
+
// var results:Array = ObjectArrayFind(aArray, aAndCriteria);
|
159
|
+
// return results[0];
|
160
|
+
// }
|
161
|
+
//
|
162
|
+
// public static function ObjectArrayLookup(aArray:Array, aAndCriteria:Object, aProperty:String):Object {
|
163
|
+
// var results:Array = ObjectArrayFind(aArray, aAndCriteria);
|
164
|
+
// var item:Object = results[0];
|
165
|
+
// if (!item)
|
166
|
+
// return null;
|
167
|
+
// return item[aProperty];
|
168
|
+
// }
|
169
|
+
|
170
|
+
_.hasMatchingProperties = function(aObject,aCriteria) {
|
171
|
+
for (var p in aCriteria) {
|
172
|
+
if (!(p in aObject) || (aObject[p]!==aCriteria[p]))
|
173
|
+
return false;
|
174
|
+
}
|
175
|
+
return true;
|
176
|
+
};
|
177
|
+
|
178
|
+
// find one item matching object properties
|
179
|
+
_.findByCriteria = function(aArray,aCriteria) {
|
180
|
+
return _.find(aArray,function(obj){
|
181
|
+
return _.hasMatchingProperties(obj,aCriteria);
|
182
|
+
});
|
183
|
+
};
|
184
|
+
|
185
|
+
// find one item matching object properties
|
186
|
+
_.filterByCriteria = function(aArray,aCriteria) {
|
187
|
+
return _.filter(aArray,function(obj){
|
188
|
+
return _.hasMatchingProperties(obj,aCriteria);
|
189
|
+
});
|
190
|
+
};
|
191
|
+
|
192
|
+
_.isObjectStrict = function(aSomething) {
|
193
|
+
return Object.prototype.toString.call(aSomething)==='[object Object]';
|
194
|
+
}
|
195
|
+
|
196
|
+
// create an object using key,value arguments eg. createObject('a',2) returns {a: 2}
|
197
|
+
_.createObject = function() {
|
198
|
+
var result = {};
|
199
|
+
result[arguments[0]] = arguments[1];
|
200
|
+
return result;
|
201
|
+
}
|
202
|
+
|
203
|
+
_.endsWith = function(aString, aSuffix) {
|
204
|
+
var i = aString.lastIndexOf(aSuffix);
|
205
|
+
return (i>=0 && i===aString.length-aSuffix.length);
|
206
|
+
}
|
207
|
+
|
208
|
+
_.beginsWith = function(aString, aPrefix) {
|
209
|
+
var i = aString.indexOf(aPrefix);
|
210
|
+
return (i==0);
|
211
|
+
}
|
212
|
+
|
213
|
+
_.chop = function(aString, aSuffix) {
|
214
|
+
var i = aString.lastIndexOf(aSuffix);
|
215
|
+
return (i===aString.length-aSuffix.length) ? aString.substring(0,i) : aString;
|
216
|
+
}
|
217
|
+
|
218
|
+
_.bite = function(aString, aPrefix) {
|
219
|
+
var i = aString.indexOf(aPrefix);
|
220
|
+
return (i===0) ? aString.substring(aPrefix.length) : aString;
|
221
|
+
}
|
222
|
+
|
223
|
+
// undefined null function arguments string number date regexp object
|
224
|
+
_.typeOf = function(aSomething) {
|
225
|
+
if (aSomething===undefined)
|
226
|
+
return 'undefined';
|
227
|
+
if (aSomething===null)
|
228
|
+
return 'null';
|
229
|
+
|
230
|
+
var result = Object.prototype.toString.call(aSomething);
|
231
|
+
result = _.bite(result,'[object ');
|
232
|
+
result = _.chop(result,']');
|
233
|
+
return result.toLowerCase();
|
234
|
+
}
|
235
|
+
|
236
|
+
/**
|
237
|
+
* Clone properties that are objects or arrays, otherwise if aSource and aDestination are different, properties will be copied
|
238
|
+
* @param aDestination
|
239
|
+
* @param aSource (optional, defaults to aSource)
|
240
|
+
* @return aDestination
|
241
|
+
*/
|
242
|
+
_.cloneComplexValues = function (aDestination, aSource) {
|
243
|
+
if (!aSource)
|
244
|
+
aSource = aDestination;
|
245
|
+
for (var p in aSource) {
|
246
|
+
var t = _.typeOf(aSource[p]);
|
247
|
+
if (t==='array' || t==='object')
|
248
|
+
aDestination[p] = _.clone(aSource[p]);
|
249
|
+
else if (aDestination!==aSource)
|
250
|
+
aDestination[p] = aSource[p];
|
251
|
+
}
|
252
|
+
return aDestination;
|
253
|
+
}
|
254
|
+
|
255
|
+
// http://justtalkaboutweb.com/2008/01/06/javascript-object-extension/
|
256
|
+
|
257
|
+
_.originalClone = _.originalClone || _.clone;
|
258
|
+
// Create a copy (shallow or deep) of an object from https://github.com/cederberg/underscore/commits/feature-clone
|
259
|
+
_.clone = function(obj, deep) {
|
260
|
+
if (!deep)
|
261
|
+
return _.originalClone(obj);
|
262
|
+
if (!_.isObject(obj) || _.isFunction(obj)) return obj;
|
263
|
+
if (_.isDate(obj)) return new Date(obj.getTime());
|
264
|
+
if (_.isRegExp(obj)) return new RegExp(obj.source, obj.toString().replace(/.*\//, ""));
|
265
|
+
var isArr = (_.isArray(obj) || _.isArguments(obj));
|
266
|
+
if (deep) {
|
267
|
+
var func = function (memo, value, key) {
|
268
|
+
if (isArr)
|
269
|
+
memo.push(_.clone(value, true));
|
270
|
+
else
|
271
|
+
memo[key] = _.clone(value, true);
|
272
|
+
return memo;
|
273
|
+
};
|
274
|
+
return _.reduce(obj, func, isArr ? [] : {});
|
275
|
+
} else {
|
276
|
+
return isArr ? slice.call(obj) : _.extend({}, obj);
|
277
|
+
}
|
278
|
+
};
|
279
|
+
|
280
|
+
_.randomString = function (aLength, aCharSet) {
|
281
|
+
var result = [];
|
282
|
+
|
283
|
+
aLength = aLength || 5;
|
284
|
+
aCharSet = aCharSet || 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
|
285
|
+
aCharSet = aCharSet.split('');
|
286
|
+
|
287
|
+
while (--aLength) {
|
288
|
+
result.push(aCharSet[Math.floor(Math.random() * aCharSet.length)]);
|
289
|
+
}
|
290
|
+
|
291
|
+
return result.join('');
|
292
|
+
};
|
293
|
+
|
294
|
+
_.formatNumber = function(aValue,aDecimals) {
|
295
|
+
if (aValue===null)
|
296
|
+
return '';
|
297
|
+
if (!aDecimals && aDecimals!==0)
|
298
|
+
aDecimals = 2;
|
299
|
+
return aValue.toFixed(aDecimals);
|
300
|
+
};
|
301
|
+
|
302
|
+
_.groupDigits = function(x) {
|
303
|
+
var parts = x.toString().split(".");
|
304
|
+
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
305
|
+
return parts.join(".");
|
306
|
+
};
|
307
|
+
|
308
|
+
_.sum = function() {
|
309
|
+
var result = NaN;
|
310
|
+
for (var i=0;i<arguments.length;i++) {
|
311
|
+
var v = arguments[i];
|
312
|
+
if (!_.isNumber(v))
|
313
|
+
return NaN;
|
314
|
+
if (i==0)
|
315
|
+
result = 0;
|
316
|
+
result += v;
|
317
|
+
}
|
318
|
+
return result;
|
319
|
+
};
|
320
|
+
|
321
|
+
_.formatCurrency = function(aNumber,aPrecision,aSymbol) {
|
322
|
+
if (!aPrecision)
|
323
|
+
aPrecision = 0;
|
324
|
+
if (!aSymbol)
|
325
|
+
aSymbol = '$';
|
326
|
+
return _.isFinite(aNumber) ? aSymbol+_.groupDigits(_.formatNumber(aNumber,aPrecision)) : '';
|
327
|
+
};
|
328
|
+
|
329
|
+
_.formatPercent = function(aNumber,aPrecision,aSymbol) {
|
330
|
+
if (!aPrecision)
|
331
|
+
aPrecision = 0;
|
332
|
+
if (!aSymbol)
|
333
|
+
aSymbol = '%';
|
334
|
+
return _.isFinite(aNumber) ? _.groupDigits(_.formatNumber(aNumber*100.0,aPrecision))+aSymbol : '';
|
335
|
+
};
|
336
|
+
|
337
|
+
_.toNull = function(aValue,aDefault) {
|
338
|
+
if (arguments.length==1)
|
339
|
+
aDefault = null;
|
340
|
+
return ((aValue===null) || (aValue===undefined) || (aValue===[]) || (aValue===0) || (aValue==={}) || _.isNaN(aValue)) ? aDefault : aValue;
|
341
|
+
}
|
342
|
+
|
343
|
+
_.toFinite = function(aValue) {
|
344
|
+
if (_.isString(aValue))
|
345
|
+
aValue = Number(aValue);
|
346
|
+
return _.isFinite(aValue) ? aValue : 0;
|
347
|
+
}
|
348
|
+
|
349
|
+
_.toInt = function(aValue,aDefault) {
|
350
|
+
if (arguments.length==1)
|
351
|
+
aDefault = null;
|
352
|
+
var t = _.typeOf(aValue);
|
353
|
+
var result;
|
354
|
+
switch(t) {
|
355
|
+
case 'undefined':
|
356
|
+
case 'null':
|
357
|
+
case 'array':
|
358
|
+
case 'object':
|
359
|
+
case 'function':
|
360
|
+
case 'class':
|
361
|
+
case 'instance':
|
362
|
+
case 'error':
|
363
|
+
result = aDefault;
|
364
|
+
break;
|
365
|
+
case 'number':
|
366
|
+
if (isNaN(aValue))
|
367
|
+
result = aDefault;
|
368
|
+
else
|
369
|
+
result = Math.round(aValue);
|
370
|
+
break;
|
371
|
+
case 'string':
|
372
|
+
result = Math.round(Number(aValue));
|
373
|
+
break;
|
374
|
+
case 'boolean':
|
375
|
+
result = aValue ? 1 : 0;
|
376
|
+
break;
|
377
|
+
default:
|
378
|
+
result = aDefault;
|
379
|
+
break;
|
380
|
+
}
|
381
|
+
return result;
|
382
|
+
};
|
383
|
+
|
384
|
+
_.toBoolean = function(aValue,aDefault) {
|
385
|
+
if (arguments.length==1)
|
386
|
+
aDefault = false;
|
387
|
+
if (aValue===true || aValue===false)
|
388
|
+
return aValue;
|
389
|
+
if (aValue===0)
|
390
|
+
return false;
|
391
|
+
if (_.isString(aValue)) {
|
392
|
+
var t = Number(aValue);
|
393
|
+
if (_.isFinite(t)) {
|
394
|
+
return !!t;
|
395
|
+
} else {
|
396
|
+
t = aValue.toLowerCase();
|
397
|
+
if (t==="true" || t==="yes" || t==="on")
|
398
|
+
return true;
|
399
|
+
if (t==="false" || t==="no" || t==="off")
|
400
|
+
return false;
|
401
|
+
}
|
402
|
+
}
|
403
|
+
return aDefault;
|
404
|
+
};
|
405
|
+
|
406
|
+
// converts simple object to array of object with id and name fields
|
407
|
+
// eg.
|
408
|
+
// _.expand_options({"cash": "Cash","consumer_mortgage": "Consumer Mortgage")
|
409
|
+
// => [{id: "cash", name:"Cash"}, {id: "consumer_mortgage",name: "Consumer Mortgage"}]
|
410
|
+
// _.expand_options(["cash","consumer_mortgage"])
|
411
|
+
// => [{id: "cash", name:"cash"}, {id: "consumer_mortgage",name: "consumer_mortgage"}]
|
412
|
+
_.expand_options = function(aObject,aIdField,aNameField) {
|
413
|
+
if (!aIdField)
|
414
|
+
aIdField = 'id';
|
415
|
+
if (!aNameField)
|
416
|
+
aNameField = 'name';
|
417
|
+
if (_.isArray(aObject)) {
|
418
|
+
return _.map(aObject,function(v){
|
419
|
+
var result = {};
|
420
|
+
result[aIdField] = v;
|
421
|
+
result[aNameField] = String(v);
|
422
|
+
return result;
|
423
|
+
});
|
424
|
+
} else {
|
425
|
+
return _.map(aObject,function(v,k){
|
426
|
+
var result = {};
|
427
|
+
result[aIdField] = k;
|
428
|
+
result[aNameField] = v;
|
429
|
+
return result;
|
430
|
+
});
|
431
|
+
}
|
432
|
+
};
|
433
|
+
|
434
|
+
// returns array of keys on object beginning with aPrefix
|
435
|
+
_.keysWithPrefix = function(aObject,aPrefix) {
|
436
|
+
var results = [];
|
437
|
+
var keys = _.keys(aObject);
|
438
|
+
for (var i=0;i<keys.length;i++) {
|
439
|
+
var k = keys[i];
|
440
|
+
if (!_.beginsWith(k,aPrefix))
|
441
|
+
continue;
|
442
|
+
results.push(k);
|
443
|
+
}
|
444
|
+
return results;
|
445
|
+
};
|
446
|
+
|
447
|
+
// returns copy of object containing only properties beginning with aPrefix
|
448
|
+
_.pickWithPrefix = function(aObject,aPrefix) {
|
449
|
+
var result = {};
|
450
|
+
_.each(aObject,function(v, k){
|
451
|
+
if (!_.beginsWith(k,aPrefix))
|
452
|
+
return;
|
453
|
+
result[k] = v;
|
454
|
+
});
|
455
|
+
return result;
|
456
|
+
};
|
457
|
+
|
458
|
+
}).call(this);
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'underscore_plus/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "underscore_plus"
|
8
|
+
spec.version = UnderscorePlus::VERSION
|
9
|
+
spec.authors = ["Gary McGhee"]
|
10
|
+
spec.email = ["contact@buzzware.com.au"]
|
11
|
+
spec.description = "Additions to underscore as a rails pipeline asset"
|
12
|
+
spec.summary = "Additions to underscore as a rails pipeline asset"
|
13
|
+
spec.homepage = "https://github.com/buzzware/underscore_plus"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
spec.add_dependency "railties", "~> 3.1"
|
21
|
+
spec.add_dependency "underscore-rails", "= 1.4.3"
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
23
|
+
spec.add_development_dependency "rake"
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: underscore_plus
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.9.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Gary McGhee
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-08-21 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: railties
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.1'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.1'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: underscore-rails
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.4.3
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.4.3
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.3'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ! '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: Additions to underscore as a rails pipeline asset
|
70
|
+
email:
|
71
|
+
- contact@buzzware.com.au
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- .gitignore
|
77
|
+
- Gemfile
|
78
|
+
- LICENSE.txt
|
79
|
+
- README.md
|
80
|
+
- Rakefile
|
81
|
+
- app/assets/javascripts/underscore_plus.js
|
82
|
+
- lib/underscore_plus.rb
|
83
|
+
- lib/underscore_plus/version.rb
|
84
|
+
- underscore_plus.gemspec
|
85
|
+
homepage: https://github.com/buzzware/underscore_plus
|
86
|
+
licenses:
|
87
|
+
- MIT
|
88
|
+
metadata: {}
|
89
|
+
post_install_message:
|
90
|
+
rdoc_options: []
|
91
|
+
require_paths:
|
92
|
+
- lib
|
93
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ! '>='
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ! '>='
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
requirements: []
|
104
|
+
rubyforge_project:
|
105
|
+
rubygems_version: 2.0.3
|
106
|
+
signing_key:
|
107
|
+
specification_version: 4
|
108
|
+
summary: Additions to underscore as a rails pipeline asset
|
109
|
+
test_files: []
|
110
|
+
has_rdoc:
|