underscore-rails 1.4.4 → 1.5.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 286bd9442baeafa07471d15d84985adbfd8e79d7
4
+ data.tar.gz: 0a258dd89f728e9c245e80cb7722d73187ce666f
5
+ SHA512:
6
+ metadata.gz: b40555f186dada31374297d07df18e550a080274b4e9745f1d45988775f7ac479552589a8dfe4babddb1ff761e8f9ae8805245e0635d9dce5dd2e6e5111ce1a7
7
+ data.tar.gz: e1deef85e8268f0f8963e84e651c422d67156f216ae297772046e8977b037cb44cd00dc6ffbe5caa15724de7894f011551c19b8d4bd8a9f2abaa942afd272502
@@ -1,5 +1,5 @@
1
1
  module Underscore
2
2
  module Rails
3
- VERSION = "1.4.4"
3
+ VERSION = "1.5.1"
4
4
  end
5
5
  end
@@ -1,6 +1,6 @@
1
- // Underscore.js 1.4.4
1
+ // Underscore.js 1.5.1
2
2
  // http://underscorejs.org
3
- // (c) 2009-2013 Jeremy Ashkenas, DocumentCloud Inc.
3
+ // (c) 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
4
4
  // Underscore may be freely distributed under the MIT license.
5
5
 
6
6
  (function() {
@@ -21,11 +21,12 @@
21
21
  var ArrayProto = Array.prototype, ObjProto = Object.prototype, FuncProto = Function.prototype;
22
22
 
23
23
  // Create quick reference variables for speed access to core prototypes.
24
- var push = ArrayProto.push,
25
- slice = ArrayProto.slice,
26
- concat = ArrayProto.concat,
27
- toString = ObjProto.toString,
28
- hasOwnProperty = ObjProto.hasOwnProperty;
24
+ var
25
+ push = ArrayProto.push,
26
+ slice = ArrayProto.slice,
27
+ concat = ArrayProto.concat,
28
+ toString = ObjProto.toString,
29
+ hasOwnProperty = ObjProto.hasOwnProperty;
29
30
 
30
31
  // All **ECMAScript 5** native function implementations that we hope to use
31
32
  // are declared here.
@@ -64,7 +65,7 @@
64
65
  }
65
66
 
66
67
  // Current version.
67
- _.VERSION = '1.4.4';
68
+ _.VERSION = '1.5.1';
68
69
 
69
70
  // Collection Functions
70
71
  // --------------------
@@ -96,7 +97,7 @@
96
97
  if (obj == null) return results;
97
98
  if (nativeMap && obj.map === nativeMap) return obj.map(iterator, context);
98
99
  each(obj, function(value, index, list) {
99
- results[results.length] = iterator.call(context, value, index, list);
100
+ results.push(iterator.call(context, value, index, list));
100
101
  });
101
102
  return results;
102
103
  };
@@ -171,7 +172,7 @@
171
172
  if (obj == null) return results;
172
173
  if (nativeFilter && obj.filter === nativeFilter) return obj.filter(iterator, context);
173
174
  each(obj, function(value, index, list) {
174
- if (iterator.call(context, value, index, list)) results[results.length] = value;
175
+ if (iterator.call(context, value, index, list)) results.push(value);
175
176
  });
176
177
  return results;
177
178
  };
@@ -255,7 +256,7 @@
255
256
 
256
257
  // Return the maximum element or (element-based computation).
257
258
  // Can't optimize arrays of integers longer than 65,535 elements.
258
- // See: https://bugs.webkit.org/show_bug.cgi?id=80797
259
+ // See [WebKit Bug 80797](https://bugs.webkit.org/show_bug.cgi?id=80797)
259
260
  _.max = function(obj, iterator, context) {
260
261
  if (!iterator && _.isArray(obj) && obj[0] === +obj[0] && obj.length < 65535) {
261
262
  return Math.max.apply(Math, obj);
@@ -264,7 +265,7 @@
264
265
  var result = {computed : -Infinity, value: -Infinity};
265
266
  each(obj, function(value, index, list) {
266
267
  var computed = iterator ? iterator.call(context, value, index, list) : value;
267
- computed >= result.computed && (result = {value : value, computed : computed});
268
+ computed > result.computed && (result = {value : value, computed : computed});
268
269
  });
269
270
  return result.value;
270
271
  };
@@ -363,7 +364,7 @@
363
364
  return low;
364
365
  };
365
366
 
366
- // Safely convert anything iterable into a real, live array.
367
+ // Safely create a real, live array from anything iterable.
367
368
  _.toArray = function(obj) {
368
369
  if (!obj) return [];
369
370
  if (_.isArray(obj)) return slice.call(obj);
@@ -422,8 +423,11 @@
422
423
 
423
424
  // Internal implementation of a recursive `flatten` function.
424
425
  var flatten = function(input, shallow, output) {
426
+ if (shallow && _.every(input, _.isArray)) {
427
+ return concat.apply(output, input);
428
+ }
425
429
  each(input, function(value) {
426
- if (_.isArray(value)) {
430
+ if (_.isArray(value) || _.isArguments(value)) {
427
431
  shallow ? push.apply(output, value) : flatten(value, shallow, output);
428
432
  } else {
429
433
  output.push(value);
@@ -466,7 +470,7 @@
466
470
  // Produce an array that contains the union: each distinct element from all of
467
471
  // the passed-in arrays.
468
472
  _.union = function() {
469
- return _.uniq(concat.apply(ArrayProto, arguments));
473
+ return _.uniq(_.flatten(arguments, true));
470
474
  };
471
475
 
472
476
  // Produce an array that contains every item shared between all the
@@ -490,11 +494,10 @@
490
494
  // Zip together multiple lists into a single array -- elements that share
491
495
  // an index go together.
492
496
  _.zip = function() {
493
- var args = slice.call(arguments);
494
- var length = _.max(_.pluck(args, 'length'));
497
+ var length = _.max(_.pluck(arguments, "length").concat(0));
495
498
  var results = new Array(length);
496
499
  for (var i = 0; i < length; i++) {
497
- results[i] = _.pluck(args, "" + i);
500
+ results[i] = _.pluck(arguments, '' + i);
498
501
  }
499
502
  return results;
500
503
  };
@@ -582,7 +585,7 @@
582
585
  // available.
583
586
  _.bind = function(func, context) {
584
587
  var args, bound;
585
- if (func.bind === nativeBind && nativeBind) return nativeBind.apply(func, slice.call(arguments, 1));
588
+ if (nativeBind && func.bind === nativeBind) return nativeBind.apply(func, slice.call(arguments, 1));
586
589
  if (!_.isFunction(func)) throw new TypeError;
587
590
  args = slice.call(arguments, 2);
588
591
  return bound = function() {
@@ -638,17 +641,23 @@
638
641
  };
639
642
 
640
643
  // Returns a function, that, when invoked, will only be triggered at most once
641
- // during a given window of time.
642
- _.throttle = function(func, wait) {
643
- var context, args, timeout, result;
644
+ // during a given window of time. Normally, the throttled function will run
645
+ // as much as it can, without ever going more than once per `wait` duration;
646
+ // but if you'd like to disable the execution on the leading edge, pass
647
+ // `{leading: false}`. To disable execution on the trailing edge, ditto.
648
+ _.throttle = function(func, wait, options) {
649
+ var context, args, result;
650
+ var timeout = null;
644
651
  var previous = 0;
652
+ options || (options = {});
645
653
  var later = function() {
646
- previous = new Date;
654
+ previous = options.leading === false ? 0 : new Date;
647
655
  timeout = null;
648
656
  result = func.apply(context, args);
649
657
  };
650
658
  return function() {
651
659
  var now = new Date;
660
+ if (!previous && options.leading === false) previous = now;
652
661
  var remaining = wait - (now - previous);
653
662
  context = this;
654
663
  args = arguments;
@@ -657,7 +666,7 @@
657
666
  timeout = null;
658
667
  previous = now;
659
668
  result = func.apply(context, args);
660
- } else if (!timeout) {
669
+ } else if (!timeout && options.trailing !== false) {
661
670
  timeout = setTimeout(later, remaining);
662
671
  }
663
672
  return result;
@@ -669,7 +678,8 @@
669
678
  // N milliseconds. If `immediate` is passed, trigger the function on the
670
679
  // leading edge, instead of the trailing.
671
680
  _.debounce = function(func, wait, immediate) {
672
- var timeout, result;
681
+ var result;
682
+ var timeout = null;
673
683
  return function() {
674
684
  var context = this, args = arguments;
675
685
  var later = function() {
@@ -723,7 +733,6 @@
723
733
 
724
734
  // Returns a function that will only be executed after being called N times.
725
735
  _.after = function(times, func) {
726
- if (times <= 0) return func();
727
736
  return function() {
728
737
  if (--times < 1) {
729
738
  return func.apply(this, arguments);
@@ -739,7 +748,7 @@
739
748
  _.keys = nativeKeys || function(obj) {
740
749
  if (obj !== Object(obj)) throw new TypeError('Invalid object');
741
750
  var keys = [];
742
- for (var key in obj) if (_.has(obj, key)) keys[keys.length] = key;
751
+ for (var key in obj) if (_.has(obj, key)) keys.push(key);
743
752
  return keys;
744
753
  };
745
754
 
@@ -835,7 +844,7 @@
835
844
  // Internal recursive comparison function for `isEqual`.
836
845
  var eq = function(a, b, aStack, bStack) {
837
846
  // Identical objects are equal. `0 === -0`, but they aren't identical.
838
- // See the Harmony `egal` proposal: http://wiki.ecmascript.org/doku.php?id=harmony:egal.
847
+ // See the [Harmony `egal` proposal](http://wiki.ecmascript.org/doku.php?id=harmony:egal).
839
848
  if (a === b) return a !== 0 || 1 / a == 1 / b;
840
849
  // A strict comparison is necessary because `null == undefined`.
841
850
  if (a == null || b == null) return a === b;
@@ -877,6 +886,13 @@
877
886
  // unique nested structures.
878
887
  if (aStack[length] == a) return bStack[length] == b;
879
888
  }
889
+ // Objects with different constructors are not equivalent, but `Object`s
890
+ // from different frames are.
891
+ var aCtor = a.constructor, bCtor = b.constructor;
892
+ if (aCtor !== bCtor && !(_.isFunction(aCtor) && (aCtor instanceof aCtor) &&
893
+ _.isFunction(bCtor) && (bCtor instanceof bCtor))) {
894
+ return false;
895
+ }
880
896
  // Add the first object to the stack of traversed objects.
881
897
  aStack.push(a);
882
898
  bStack.push(b);
@@ -893,13 +909,6 @@
893
909
  }
894
910
  }
895
911
  } else {
896
- // Objects with different constructors are not equivalent, but `Object`s
897
- // from different frames are.
898
- var aCtor = a.constructor, bCtor = b.constructor;
899
- if (aCtor !== bCtor && !(_.isFunction(aCtor) && (aCtor instanceof aCtor) &&
900
- _.isFunction(bCtor) && (bCtor instanceof bCtor))) {
901
- return false;
902
- }
903
912
  // Deep compare objects.
904
913
  for (var key in a) {
905
914
  if (_.has(a, key)) {
@@ -1023,7 +1032,7 @@
1023
1032
 
1024
1033
  // Run a function **n** times.
1025
1034
  _.times = function(n, iterator, context) {
1026
- var accum = Array(n);
1035
+ var accum = Array(Math.max(0, n));
1027
1036
  for (var i = 0; i < n; i++) accum[i] = iterator.call(context, i);
1028
1037
  return accum;
1029
1038
  };
@@ -1044,8 +1053,7 @@
1044
1053
  '<': '&lt;',
1045
1054
  '>': '&gt;',
1046
1055
  '"': '&quot;',
1047
- "'": '&#x27;',
1048
- '/': '&#x2F;'
1056
+ "'": '&#x27;'
1049
1057
  }
1050
1058
  };
1051
1059
  entityMap.unescape = _.invert(entityMap.escape);
@@ -1066,8 +1074,8 @@
1066
1074
  };
1067
1075
  });
1068
1076
 
1069
- // If the value of the named property is a function then invoke it;
1070
- // otherwise, return it.
1077
+ // If the value of the named `property` is a function then invoke it with the
1078
+ // `object` as context; otherwise, return it.
1071
1079
  _.result = function(object, property) {
1072
1080
  if (object == null) return void 0;
1073
1081
  var value = object[property];
@@ -1234,4 +1242,4 @@
1234
1242
 
1235
1243
  });
1236
1244
 
1237
- }).call(this);
1245
+ }).call(this);
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: underscore-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.4
5
- prerelease:
4
+ version: 1.5.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Robin Wenglewski
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-04-04 00:00:00.000000000 Z
11
+ date: 2013-07-12 00:00:00.000000000 Z
13
12
  dependencies: []
14
13
  description:
15
14
  email:
@@ -28,26 +27,25 @@ files:
28
27
  - vendor/assets/javascripts/underscore.js
29
28
  homepage: https://github.com/rweng/underscore-rails
30
29
  licenses: []
30
+ metadata: {}
31
31
  post_install_message:
32
32
  rdoc_options: []
33
33
  require_paths:
34
34
  - lib
35
35
  required_ruby_version: !ruby/object:Gem::Requirement
36
- none: false
37
36
  requirements:
38
- - - ! '>='
37
+ - - '>='
39
38
  - !ruby/object:Gem::Version
40
39
  version: '0'
41
40
  required_rubygems_version: !ruby/object:Gem::Requirement
42
- none: false
43
41
  requirements:
44
- - - ! '>='
42
+ - - '>='
45
43
  - !ruby/object:Gem::Version
46
44
  version: '0'
47
45
  requirements: []
48
46
  rubyforge_project: underscore-rails
49
- rubygems_version: 1.8.23
47
+ rubygems_version: 2.0.3
50
48
  signing_key:
51
- specification_version: 3
49
+ specification_version: 4
52
50
  summary: underscore.js asset pipeline provider/wrapper
53
51
  test_files: []