ultimate-base 0.6.2 → 0.7.2
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.
- data/app/assets/javascripts/ultimate/backbone/app.js.coffee +23 -2
- data/app/assets/javascripts/ultimate/backbone/lib/backbone.js +213 -178
- data/app/assets/javascripts/ultimate/backbone/view.js.coffee +8 -9
- data/app/assets/javascripts/ultimate/helpers.js.coffee.erb +15 -2
- data/app/assets/javascripts/ultimate/underscore/underscore.js +219 -125
- data/app/assets/javascripts/ultimate/underscore/underscore.outcasts.js.coffee +16 -2
- data/app/assets/javascripts/ultimate/underscore/underscore.string.js +38 -9
- data/lib/ultimate/base/version.rb +1 -1
- metadata +2 -2
@@ -4,7 +4,7 @@
|
|
4
4
|
Underscore.outcasts is freely distributable under the terms of the MIT license.
|
5
5
|
Documentation: https://github.com/KODerFunk/underscore.outcasts
|
6
6
|
Some code is borrowed from outcasts pull requests to Underscore.
|
7
|
-
Version '0.1.
|
7
|
+
Version '0.1.6'
|
8
8
|
###
|
9
9
|
|
10
10
|
'use strict'
|
@@ -15,7 +15,7 @@
|
|
15
15
|
|
16
16
|
UnderscoreOutcasts =
|
17
17
|
|
18
|
-
VERSION: '0.1.
|
18
|
+
VERSION: '0.1.6'
|
19
19
|
|
20
20
|
delete: (object, key) ->
|
21
21
|
value = object[key]
|
@@ -176,6 +176,20 @@ UnderscoreOutcasts =
|
|
176
176
|
else
|
177
177
|
groups
|
178
178
|
|
179
|
+
###
|
180
|
+
Create a (deep-cloned) duplicate of an object.
|
181
|
+
###
|
182
|
+
# TODO tests
|
183
|
+
deepClone: (obj) ->
|
184
|
+
return obj unless _.isObject(obj)
|
185
|
+
if _.isArray(obj)
|
186
|
+
@deepClone(element) for element in obj
|
187
|
+
else
|
188
|
+
newObj = {}
|
189
|
+
if obj
|
190
|
+
for prop, value of obj when not _.isFunction(value)
|
191
|
+
newObj[prop] = @deepClone(value)
|
192
|
+
newObj
|
179
193
|
|
180
194
|
|
181
195
|
exports: ->
|
@@ -3,7 +3,7 @@
|
|
3
3
|
// Underscore.string is freely distributable under the terms of the MIT license.
|
4
4
|
// Documentation: https://github.com/epeli/underscore.string
|
5
5
|
// Some code is borrowed from MooTools and Alexandru Marasteanu.
|
6
|
-
// Version '2.3.
|
6
|
+
// Version '2.3.2'
|
7
7
|
|
8
8
|
!function(root, String){
|
9
9
|
'use strict';
|
@@ -37,6 +37,18 @@
|
|
37
37
|
return '[' + _s.escapeRegExp(characters) + ']';
|
38
38
|
};
|
39
39
|
|
40
|
+
// Helper for toBoolean
|
41
|
+
function boolMatch(s, matchers) {
|
42
|
+
var i, matcher, down = s.toLowerCase();
|
43
|
+
matchers = [].concat(matchers);
|
44
|
+
for (i = 0; i < matchers.length; i += 1) {
|
45
|
+
matcher = matchers[i];
|
46
|
+
if (!matcher) continue;
|
47
|
+
if (matcher.test && matcher.test(s)) return true;
|
48
|
+
if (matcher.toLowerCase() === down) return true;
|
49
|
+
}
|
50
|
+
}
|
51
|
+
|
40
52
|
var escapeChars = {
|
41
53
|
lt: '<',
|
42
54
|
gt: '>',
|
@@ -320,11 +332,12 @@
|
|
320
332
|
|
321
333
|
titleize: function(str){
|
322
334
|
if (str == null) return '';
|
323
|
-
|
335
|
+
str = String(str).toLowerCase();
|
336
|
+
return str.replace(/(?:^|\s|-)\S/g, function(c){ return c.toUpperCase(); });
|
324
337
|
},
|
325
338
|
|
326
339
|
camelize: function(str){
|
327
|
-
return _s.trim(str).replace(/[-_\s]+(.)?/g, function(match, c){ return c.toUpperCase(); });
|
340
|
+
return _s.trim(str).replace(/[-_\s]+(.)?/g, function(match, c){ return c ? c.toUpperCase() : ""; });
|
328
341
|
},
|
329
342
|
|
330
343
|
underscored: function(str){
|
@@ -492,8 +505,8 @@
|
|
492
505
|
},
|
493
506
|
|
494
507
|
toSentence: function(array, separator, lastSeparator, serial) {
|
495
|
-
separator = separator || ', '
|
496
|
-
lastSeparator = lastSeparator || ' and '
|
508
|
+
separator = separator || ', ';
|
509
|
+
lastSeparator = lastSeparator || ' and ';
|
497
510
|
var a = array.slice(), lastMember = a.pop();
|
498
511
|
|
499
512
|
if (array.length > 2 && serial) lastSeparator = _s.rtrim(separator) + lastSeparator;
|
@@ -510,8 +523,8 @@
|
|
510
523
|
slugify: function(str) {
|
511
524
|
if (str == null) return '';
|
512
525
|
|
513
|
-
var from = "
|
514
|
-
to = "
|
526
|
+
var from = "ąàáäâãåæăćęèéëêìíïîłńòóöôõøśșțùúüûñçżź",
|
527
|
+
to = "aaaaaaaaaceeeeeiiiilnoooooosstuuuunczz",
|
515
528
|
regex = new RegExp(defaultToWhiteSpace(from), 'g');
|
516
529
|
|
517
530
|
str = String(str).toLowerCase().replace(regex, function(c){
|
@@ -526,8 +539,15 @@
|
|
526
539
|
return [wrapper, str, wrapper].join('');
|
527
540
|
},
|
528
541
|
|
529
|
-
quote: function(str) {
|
530
|
-
return _s.surround(str, '"');
|
542
|
+
quote: function(str, quoteChar) {
|
543
|
+
return _s.surround(str, quoteChar || '"');
|
544
|
+
},
|
545
|
+
|
546
|
+
unquote: function(str, quoteChar) {
|
547
|
+
quoteChar = quoteChar || '"';
|
548
|
+
if (str[0] === quoteChar && str[str.length-1] === quoteChar)
|
549
|
+
return str.slice(1,str.length-1);
|
550
|
+
else return str;
|
531
551
|
},
|
532
552
|
|
533
553
|
exports: function() {
|
@@ -608,6 +628,14 @@
|
|
608
628
|
}
|
609
629
|
|
610
630
|
return current.pop();
|
631
|
+
},
|
632
|
+
|
633
|
+
toBoolean: function(str, trueValues, falseValues) {
|
634
|
+
if (typeof str === "number") str = "" + str;
|
635
|
+
if (typeof str !== "string") return !!str;
|
636
|
+
str = _s.trim(str);
|
637
|
+
if (boolMatch(str, trueValues || ["true", "1"])) return true;
|
638
|
+
if (boolMatch(str, falseValues || ["false", "0"])) return false;
|
611
639
|
}
|
612
640
|
};
|
613
641
|
|
@@ -621,6 +649,7 @@
|
|
621
649
|
_s.ljust = _s.rpad;
|
622
650
|
_s.contains = _s.include;
|
623
651
|
_s.q = _s.quote;
|
652
|
+
_s.toBool = _s.toBoolean;
|
624
653
|
|
625
654
|
// Exporting
|
626
655
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ultimate-base
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2015-09-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|