underscore_extensions 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
data/.rvmrc
CHANGED
@@ -1 +1 @@
|
|
1
|
-
rvm 1.9.3-
|
1
|
+
rvm 1.9.3-p327-perf@underscore_extensions --create
|
@@ -13,39 +13,7 @@
|
|
13
13
|
}, obj);
|
14
14
|
}
|
15
15
|
|
16
|
-
function mergeSort(array, comparison) {
|
17
|
-
function merge(left, right, comparison) {
|
18
|
-
var result = [];
|
19
|
-
while ((left.length > 0) && (right.length > 0)) {
|
20
|
-
if (comparison(left[0], right[0]) <= 0) {
|
21
|
-
result.push(left.shift());
|
22
|
-
} else {
|
23
|
-
result.push(right.shift());
|
24
|
-
}
|
25
|
-
}
|
26
|
-
while (left.length > 0) {
|
27
|
-
result.push(left.shift());
|
28
|
-
}
|
29
|
-
while (right.length > 0) {
|
30
|
-
result.push(right.shift());
|
31
|
-
}
|
32
|
-
return result;
|
33
|
-
}
|
34
|
-
|
35
|
-
if (array.length < 2) {
|
36
|
-
return array;
|
37
|
-
}
|
38
|
-
var middle = Math.ceil(array.length / 2);
|
39
|
-
return merge(mergeSort(array.slice(0, middle), comparison), mergeSort(array.slice(middle), comparison), comparison);
|
40
|
-
}
|
41
|
-
|
42
16
|
_.mixin({
|
43
|
-
classify: function(str) {
|
44
|
-
var s = _(str).trim().replace(/(\-|_|\s)+(.)?/g, function(match, separator, chr) {
|
45
|
-
return chr ? chr.toUpperCase() : '';
|
46
|
-
});
|
47
|
-
return s.charAt(0).toUpperCase() + s.substring(1);
|
48
|
-
},
|
49
17
|
namespace: function(obj, ns) {
|
50
18
|
if (arguments.length === 2) {
|
51
19
|
if (_(ns).isArray()) {
|
@@ -56,30 +24,6 @@
|
|
56
24
|
} else {
|
57
25
|
return namespace(obj, Array.prototype.slice.call(arguments, 1));
|
58
26
|
}
|
59
|
-
},
|
60
|
-
stableSortBy: function(obj, val, context) {
|
61
|
-
var iterator = _.isFunction(val) ? val : function(obj) {
|
62
|
-
return obj[val];
|
63
|
-
};
|
64
|
-
var toSort = _.map(obj, function(value, index, list) {
|
65
|
-
return {
|
66
|
-
value: value,
|
67
|
-
criteria: iterator.call(context, value, index, list)
|
68
|
-
};
|
69
|
-
});
|
70
|
-
var comparator = function(left, right) {
|
71
|
-
var a = left.criteria, b = right.criteria;
|
72
|
-
if (a === void 0) {
|
73
|
-
return 1;
|
74
|
-
}
|
75
|
-
if (b === void 0) {
|
76
|
-
return -1;
|
77
|
-
}
|
78
|
-
return a < b ? -1 : a > b ? 1 : 0;
|
79
|
-
};
|
80
|
-
|
81
|
-
toSort = mergeSort(toSort, comparator);
|
82
|
-
return _.pluck(toSort, 'value');
|
83
27
|
}
|
84
28
|
});
|
85
29
|
|
@@ -92,12 +92,4 @@ describe('_', function() {
|
|
92
92
|
expect(_('foos').singularize({skip: 'foos'})).toEqual('foos');
|
93
93
|
});
|
94
94
|
});
|
95
|
-
|
96
|
-
describe("#stableSortBy", function() {
|
97
|
-
it("should sort the items by the provided iterator, through a stable sort", function() {
|
98
|
-
var toSort = [{a: 1}, {b: 1}, {c: 1}, {d: 1}, {e: 2}, {f:1}, {g: 1}];
|
99
|
-
var sorted = _(toSort).stableSortBy(function(obj) { return _(obj).values()[0]; });
|
100
|
-
expect(sorted).toEqual([{a: 1}, {b: 1}, {c: 1}, {d: 1}, {f:1}, {g: 1}, {e: 2}]);
|
101
|
-
});
|
102
|
-
});
|
103
95
|
});
|
@@ -494,7 +494,7 @@
|
|
494
494
|
slugify: function(str) {
|
495
495
|
if (str == null) return '';
|
496
496
|
|
497
|
-
var from = "
|
497
|
+
var from = "ąà áäâãåæćęèéëêìÃïîłńòóöôõøùúüûñçżź",
|
498
498
|
to = "aaaaaaaaceeeeeiiiilnoooooouuuunczz",
|
499
499
|
regex = new RegExp(defaultToWhiteSpace(from), 'g');
|
500
500
|
|
@@ -597,4 +597,4 @@
|
|
597
597
|
root._.string = root._.str = _s;
|
598
598
|
}
|
599
599
|
|
600
|
-
}(this, String);
|
600
|
+
}(this, String);
|
metadata
CHANGED
@@ -1,112 +1,96 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: underscore_extensions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.0
|
5
4
|
prerelease:
|
5
|
+
version: 0.2.1
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Ryan Dy
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-12-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
+
version_requirements: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ! '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
none: false
|
21
|
+
prerelease: false
|
15
22
|
name: fuubar
|
16
23
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
24
|
requirements:
|
19
25
|
- - ! '>='
|
20
26
|
- !ruby/object:Gem::Version
|
21
27
|
version: '0'
|
28
|
+
none: false
|
22
29
|
type: :development
|
23
|
-
|
30
|
+
- !ruby/object:Gem::Dependency
|
24
31
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
32
|
requirements:
|
27
33
|
- - ! '>='
|
28
34
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
30
|
-
|
35
|
+
version: 1.2.1
|
36
|
+
none: false
|
37
|
+
prerelease: false
|
31
38
|
name: jasmine
|
32
39
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
40
|
requirements:
|
35
41
|
- - ! '>='
|
36
42
|
- !ruby/object:Gem::Version
|
37
43
|
version: 1.2.1
|
44
|
+
none: false
|
38
45
|
type: :development
|
39
|
-
|
46
|
+
- !ruby/object:Gem::Dependency
|
40
47
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
48
|
requirements:
|
43
49
|
- - ! '>='
|
44
50
|
- !ruby/object:Gem::Version
|
45
|
-
version:
|
46
|
-
|
51
|
+
version: '0'
|
52
|
+
none: false
|
53
|
+
prerelease: false
|
47
54
|
name: jshint_on_rails
|
48
55
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
56
|
requirements:
|
51
57
|
- - ! '>='
|
52
58
|
- !ruby/object:Gem::Version
|
53
59
|
version: '0'
|
60
|
+
none: false
|
54
61
|
type: :development
|
55
|
-
|
62
|
+
- !ruby/object:Gem::Dependency
|
56
63
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
64
|
requirements:
|
59
65
|
- - ! '>='
|
60
66
|
- !ruby/object:Gem::Version
|
61
67
|
version: '0'
|
62
|
-
|
68
|
+
none: false
|
69
|
+
prerelease: false
|
63
70
|
name: thin
|
64
71
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
72
|
requirements:
|
67
73
|
- - ! '>='
|
68
74
|
- !ruby/object:Gem::Version
|
69
75
|
version: '0'
|
70
|
-
type: :development
|
71
|
-
prerelease: false
|
72
|
-
version_requirements: !ruby/object:Gem::Requirement
|
73
76
|
none: false
|
74
|
-
|
75
|
-
- - ! '>='
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
version: '0'
|
77
|
+
type: :development
|
78
78
|
- !ruby/object:Gem::Dependency
|
79
|
-
name: rails
|
80
|
-
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
|
-
requirements:
|
83
|
-
- - ! '>='
|
84
|
-
- !ruby/object:Gem::Version
|
85
|
-
version: '3.1'
|
86
|
-
type: :runtime
|
87
|
-
prerelease: false
|
88
79
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
80
|
requirements:
|
91
81
|
- - ! '>='
|
92
82
|
- !ruby/object:Gem::Version
|
93
83
|
version: '3.1'
|
94
|
-
|
84
|
+
none: false
|
85
|
+
prerelease: false
|
95
86
|
name: rails
|
96
87
|
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
88
|
requirements:
|
99
89
|
- - ! '>='
|
100
90
|
- !ruby/object:Gem::Version
|
101
91
|
version: '3.1'
|
102
|
-
type: :runtime
|
103
|
-
prerelease: false
|
104
|
-
version_requirements: !ruby/object:Gem::Requirement
|
105
92
|
none: false
|
106
|
-
|
107
|
-
- - ! '>='
|
108
|
-
- !ruby/object:Gem::Version
|
109
|
-
version: '3.1'
|
93
|
+
type: :runtime
|
110
94
|
description: Adds extensions to the underscore javascript library. It adds the javascript
|
111
95
|
as a rails engine to be included in to a Rails 3+ project. To use it make sure require
|
112
96
|
underscore, underscore.string and underscore.extensions.
|
@@ -140,20 +124,26 @@ rdoc_options: []
|
|
140
124
|
require_paths:
|
141
125
|
- lib
|
142
126
|
required_ruby_version: !ruby/object:Gem::Requirement
|
143
|
-
none: false
|
144
127
|
requirements:
|
145
128
|
- - ! '>='
|
146
129
|
- !ruby/object:Gem::Version
|
147
130
|
version: '0'
|
148
|
-
|
131
|
+
segments:
|
132
|
+
- 0
|
133
|
+
hash: -3121695875512196244
|
149
134
|
none: false
|
135
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
150
136
|
requirements:
|
151
137
|
- - ! '>='
|
152
138
|
- !ruby/object:Gem::Version
|
153
139
|
version: '0'
|
140
|
+
segments:
|
141
|
+
- 0
|
142
|
+
hash: -3121695875512196244
|
143
|
+
none: false
|
154
144
|
requirements: []
|
155
145
|
rubyforge_project: underscore_extensions
|
156
|
-
rubygems_version: 1.8.
|
146
|
+
rubygems_version: 1.8.24
|
157
147
|
signing_key:
|
158
148
|
specification_version: 3
|
159
149
|
summary: Extensions to underscore javascript library as a rails engine
|