underscore_extensions 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.rvmrc +1 -1
- data/.travis.yml +1 -0
- data/lib/assets/javascripts/underscore.extensions.js +18 -5
- data/lib/underscore_extensions/version.rb +1 -1
- data/spec/javascripts/underscore.extensions_spec.js +47 -11
- metadata +102 -110
data/.rvmrc
CHANGED
@@ -1 +1 @@
|
|
1
|
-
rvm 1.
|
1
|
+
rvm 1.9.3-perf@underscore_extensions --create
|
data/.travis.yml
CHANGED
@@ -3,6 +3,16 @@
|
|
3
3
|
_.mixin(_.str.exports());
|
4
4
|
}
|
5
5
|
|
6
|
+
function namespace(obj, ns) {
|
7
|
+
return _(ns).inject(function(base, n) {
|
8
|
+
var _baseN = _(base[n]);
|
9
|
+
if (_baseN.isUndefined() || _baseN.isNull()) {
|
10
|
+
base[n] = {};
|
11
|
+
}
|
12
|
+
return base[n];
|
13
|
+
}, obj);
|
14
|
+
}
|
15
|
+
|
6
16
|
_.mixin({
|
7
17
|
classify: function(str) {
|
8
18
|
var s = _(str).trim().replace(/(\-|_|\s)+(.)?/g, function(match, separator, chr) {
|
@@ -25,12 +35,15 @@
|
|
25
35
|
return result;
|
26
36
|
},
|
27
37
|
namespace: function(obj, ns) {
|
28
|
-
|
29
|
-
if (
|
30
|
-
|
38
|
+
if (arguments.length === 2) {
|
39
|
+
if (_(ns).isArray()) {
|
40
|
+
return namespace(obj, ns);
|
41
|
+
} else {
|
42
|
+
return namespace(obj, ns.split('.'));
|
31
43
|
}
|
32
|
-
|
33
|
-
|
44
|
+
} else {
|
45
|
+
return namespace(obj, Array.prototype.slice.call(arguments, 1));
|
46
|
+
}
|
34
47
|
},
|
35
48
|
only: function(obj) {
|
36
49
|
function only() {
|
@@ -18,19 +18,55 @@ describe('_', function() {
|
|
18
18
|
});
|
19
19
|
|
20
20
|
describe('#namespace', function() {
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
21
|
+
describe('when the namespace is passed as a single parameter with period separator', function() {
|
22
|
+
it('should create the namespace', function() {
|
23
|
+
var result = {};
|
24
|
+
baz = _(result).namespace('foo.bar.baz');
|
25
|
+
baz.property = 'property';
|
26
|
+
expect(result.foo.bar.baz).toBeDefined();
|
27
|
+
expect(result.foo.bar.baz.property).toBeDefined();
|
28
|
+
});
|
29
|
+
|
30
|
+
it('should not overwrite existing namespaces', function() {
|
31
|
+
var result = { foo: {a: 'b'}};
|
32
|
+
baz = _(result).namespace('foo.bar.baz');
|
33
|
+
expect(result.foo.bar.baz).toBeDefined();
|
34
|
+
expect(result.foo.a).toEqual('b');
|
35
|
+
});
|
27
36
|
});
|
28
37
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
38
|
+
describe('when the namespace is passed as multiple parameters', function() {
|
39
|
+
it('should create the namespace', function() {
|
40
|
+
var result = {};
|
41
|
+
baz = _(result).namespace('foo', 'bar', 'baz');
|
42
|
+
baz.property = 'property';
|
43
|
+
expect(result.foo.bar.baz).toBeDefined();
|
44
|
+
expect(result.foo.bar.baz.property).toBeDefined();
|
45
|
+
});
|
46
|
+
|
47
|
+
it('should not overwrite existing namespaces', function() {
|
48
|
+
var result = { foo: {a: 'b'}};
|
49
|
+
baz = _(result).namespace('foo', 'bar', 'baz');
|
50
|
+
expect(result.foo.bar.baz).toBeDefined();
|
51
|
+
expect(result.foo.a).toEqual('b');
|
52
|
+
});
|
53
|
+
});
|
54
|
+
|
55
|
+
describe('when the namespace is passed as an array', function() {
|
56
|
+
it('should create the namespace', function() {
|
57
|
+
var result = {};
|
58
|
+
baz = _(result).namespace(['foo', 'bar', 'baz']);
|
59
|
+
baz.property = 'property';
|
60
|
+
expect(result.foo.bar.baz).toBeDefined();
|
61
|
+
expect(result.foo.bar.baz.property).toBeDefined();
|
62
|
+
});
|
63
|
+
|
64
|
+
it('should not overwrite existing namespaces', function() {
|
65
|
+
var result = { foo: {a: 'b'}};
|
66
|
+
baz = _(result).namespace(['foo', 'bar', 'baz']);
|
67
|
+
expect(result.foo.bar.baz).toBeDefined();
|
68
|
+
expect(result.foo.a).toEqual('b');
|
69
|
+
});
|
34
70
|
});
|
35
71
|
});
|
36
72
|
|
metadata
CHANGED
@@ -1,119 +1,121 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: underscore_extensions
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 0
|
9
|
-
- 3
|
10
|
-
version: 0.0.3
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Ryan Dy
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-04-04 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
22
15
|
name: fuubar
|
23
|
-
|
24
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
25
17
|
none: false
|
26
|
-
requirements:
|
27
|
-
- -
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
|
30
|
-
segments:
|
31
|
-
- 0
|
32
|
-
version: "0"
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
33
22
|
type: :development
|
34
|
-
version_requirements: *id001
|
35
|
-
- !ruby/object:Gem::Dependency
|
36
|
-
name: jasmine
|
37
23
|
prerelease: false
|
38
|
-
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
39
25
|
none: false
|
40
|
-
requirements:
|
41
|
-
- -
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: jasmine
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
47
38
|
type: :development
|
48
|
-
version_requirements: *id002
|
49
|
-
- !ruby/object:Gem::Dependency
|
50
|
-
name: jshint_on_rails
|
51
39
|
prerelease: false
|
52
|
-
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
53
41
|
none: false
|
54
|
-
requirements:
|
55
|
-
- -
|
56
|
-
- !ruby/object:Gem::Version
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: jshint_on_rails
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
61
54
|
type: :development
|
62
|
-
version_requirements: *id003
|
63
|
-
- !ruby/object:Gem::Dependency
|
64
|
-
name: thin
|
65
55
|
prerelease: false
|
66
|
-
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: thin
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
67
65
|
none: false
|
68
|
-
requirements:
|
69
|
-
- -
|
70
|
-
- !ruby/object:Gem::Version
|
71
|
-
|
72
|
-
segments:
|
73
|
-
- 0
|
74
|
-
version: "0"
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
75
70
|
type: :development
|
76
|
-
version_requirements: *id004
|
77
|
-
- !ruby/object:Gem::Dependency
|
78
|
-
name: rails
|
79
71
|
prerelease: false
|
80
|
-
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
81
73
|
none: false
|
82
|
-
requirements:
|
83
|
-
- -
|
84
|
-
- !ruby/object:Gem::Version
|
85
|
-
|
86
|
-
|
87
|
-
- 3
|
88
|
-
- 1
|
89
|
-
version: "3.1"
|
90
|
-
type: :runtime
|
91
|
-
version_requirements: *id005
|
92
|
-
- !ruby/object:Gem::Dependency
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
93
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
|
94
87
|
prerelease: false
|
95
|
-
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
96
89
|
none: false
|
97
|
-
requirements:
|
98
|
-
- -
|
99
|
-
- !ruby/object:Gem::Version
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '3.1'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: rails
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '3.1'
|
105
102
|
type: :runtime
|
106
|
-
|
107
|
-
|
108
|
-
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '3.1'
|
110
|
+
description: Adds extensions to the underscore javascript library. It adds the javascript
|
111
|
+
as a rails engine to be included in to a Rails 3+ project. To use it make sure require
|
112
|
+
underscore, underscore.string and underscore.extensions.
|
113
|
+
email:
|
109
114
|
- ryan.dy@gmail.com
|
110
115
|
executables: []
|
111
|
-
|
112
116
|
extensions: []
|
113
|
-
|
114
117
|
extra_rdoc_files: []
|
115
|
-
|
116
|
-
files:
|
118
|
+
files:
|
117
119
|
- .gitignore
|
118
120
|
- .rvmrc
|
119
121
|
- .travis.yml
|
@@ -130,41 +132,31 @@ files:
|
|
130
132
|
- underscore_extensions.gemspec
|
131
133
|
- vendor/assets/javascripts/underscore.js
|
132
134
|
- vendor/assets/javascripts/underscore.string.js
|
133
|
-
has_rdoc: true
|
134
135
|
homepage: http://github.com/rdy/underscore_extensions
|
135
136
|
licenses: []
|
136
|
-
|
137
137
|
post_install_message:
|
138
138
|
rdoc_options: []
|
139
|
-
|
140
|
-
require_paths:
|
139
|
+
require_paths:
|
141
140
|
- lib
|
142
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
141
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
143
142
|
none: false
|
144
|
-
requirements:
|
145
|
-
- -
|
146
|
-
- !ruby/object:Gem::Version
|
147
|
-
|
148
|
-
|
149
|
-
- 0
|
150
|
-
version: "0"
|
151
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - ! '>='
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '0'
|
147
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
152
148
|
none: false
|
153
|
-
requirements:
|
154
|
-
- -
|
155
|
-
- !ruby/object:Gem::Version
|
156
|
-
|
157
|
-
segments:
|
158
|
-
- 0
|
159
|
-
version: "0"
|
149
|
+
requirements:
|
150
|
+
- - ! '>='
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
160
153
|
requirements: []
|
161
|
-
|
162
154
|
rubyforge_project: underscore_extensions
|
163
|
-
rubygems_version: 1.
|
155
|
+
rubygems_version: 1.8.19
|
164
156
|
signing_key:
|
165
157
|
specification_version: 3
|
166
158
|
summary: Extensions to underscore javascript library as a rails engine
|
167
|
-
test_files:
|
159
|
+
test_files:
|
168
160
|
- spec/javascripts/support/jasmine.yml
|
169
161
|
- spec/javascripts/support/spec_helper.js
|
170
162
|
- spec/javascripts/underscore.extensions_spec.js
|