transistor 0.1.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 +7 -0
- data/Gemfile +11 -0
- data/Gemfile.lock +57 -0
- data/README.md +96 -0
- data/Rakefile +109 -0
- data/faye-browser.js +2194 -0
- data/index.html +40 -0
- data/jake.yml +24 -0
- data/lib/transistor/binder.js +109 -0
- data/lib/transistor/control.js +62 -0
- data/lib/transistor/radio.js +67 -0
- data/lib/vendor/faye-browser-min.js +2 -0
- data/lib/vendor/jsonp.js +83 -0
- data/spec/javascripts/TransistorBinderSpec.js +273 -0
- data/spec/javascripts/helpers/AssertHelpers.js +23 -0
- data/spec/javascripts/support/jasmine.yml +9 -0
- metadata +130 -0
@@ -0,0 +1,273 @@
|
|
1
|
+
describe("Transistor.Binder", function () {
|
2
|
+
var binder, array;
|
3
|
+
|
4
|
+
beforeEach(function () {
|
5
|
+
array = [];
|
6
|
+
binder = Transistor.Binder(array);
|
7
|
+
});
|
8
|
+
|
9
|
+
describe("init event", function () {
|
10
|
+
it("throws on undefined", function () {
|
11
|
+
array.push(23);
|
12
|
+
array.push('a string');
|
13
|
+
|
14
|
+
expect(function () {
|
15
|
+
binder('init', undefined);
|
16
|
+
}).toThrow(new Error('undefined arguments'));
|
17
|
+
|
18
|
+
refuteEmpty(array);
|
19
|
+
});
|
20
|
+
|
21
|
+
it("maps arg 'empty array' to a clear", function () {
|
22
|
+
array.push(23);
|
23
|
+
array.push('a string');
|
24
|
+
|
25
|
+
binder('init', []);
|
26
|
+
|
27
|
+
assertEmpty(array);
|
28
|
+
});
|
29
|
+
|
30
|
+
it("maps arg 'array' to a clear and set", function () {
|
31
|
+
array.push(23);
|
32
|
+
array.push('a string');
|
33
|
+
|
34
|
+
binder('init', ['my', 'objects']);
|
35
|
+
|
36
|
+
assertEqual(['my', 'objects'], array);
|
37
|
+
});
|
38
|
+
});
|
39
|
+
|
40
|
+
describe("set event", function () {
|
41
|
+
it("throws on undefined args", function () {
|
42
|
+
array.push(23);
|
43
|
+
array.push('a string');
|
44
|
+
|
45
|
+
expect(function () {
|
46
|
+
binder('set', undefined);
|
47
|
+
}).toThrow(new Error('undefined arguments'));
|
48
|
+
|
49
|
+
refuteEmpty(array);
|
50
|
+
});
|
51
|
+
|
52
|
+
it("throws on undefined collection", function () {
|
53
|
+
array.push(23);
|
54
|
+
array.push('a string');
|
55
|
+
|
56
|
+
expect(function () {
|
57
|
+
binder('set', {
|
58
|
+
collection: undefined
|
59
|
+
});
|
60
|
+
}).toThrow(new Error('undefined collection'));
|
61
|
+
|
62
|
+
refuteEmpty(array);
|
63
|
+
});
|
64
|
+
|
65
|
+
it("accepts an empty array as collection", function () {
|
66
|
+
array.push(23);
|
67
|
+
array.push('a string');
|
68
|
+
|
69
|
+
binder('set', {
|
70
|
+
collection: []
|
71
|
+
});
|
72
|
+
|
73
|
+
assertEmpty(array);
|
74
|
+
});
|
75
|
+
|
76
|
+
it("accepts a filled array as collection", function () {
|
77
|
+
array.push(23);
|
78
|
+
array.push('a string');
|
79
|
+
|
80
|
+
binder('set', {
|
81
|
+
collection: ['my', 'objects']
|
82
|
+
});
|
83
|
+
|
84
|
+
assertEqual(['my', 'objects'], array);
|
85
|
+
});
|
86
|
+
});
|
87
|
+
|
88
|
+
describe("insert event", function () {
|
89
|
+
it("throws on undefined args", function () {
|
90
|
+
array.push(23);
|
91
|
+
array.push('a string');
|
92
|
+
|
93
|
+
expect(function () {
|
94
|
+
binder('insert', undefined);
|
95
|
+
}).toThrow(new Error('undefined arguments'));
|
96
|
+
|
97
|
+
refuteEmpty(array);
|
98
|
+
});
|
99
|
+
|
100
|
+
it("throws on undefined entry", function () {
|
101
|
+
array.push(23);
|
102
|
+
array.push('a string');
|
103
|
+
|
104
|
+
expect(function () {
|
105
|
+
binder('insert', {
|
106
|
+
entry: undefined
|
107
|
+
});
|
108
|
+
}).toThrow(new Error('undefined entry'));
|
109
|
+
|
110
|
+
refuteEmpty(array);
|
111
|
+
});
|
112
|
+
|
113
|
+
it("maps collection arg 'entry' to a push", function () {
|
114
|
+
array.push(23);
|
115
|
+
array.push('a string');
|
116
|
+
|
117
|
+
binder('insert', {
|
118
|
+
entry: 'my_object'
|
119
|
+
});
|
120
|
+
|
121
|
+
assertEqual([23, 'a string', 'my_object'], array);
|
122
|
+
});
|
123
|
+
});
|
124
|
+
|
125
|
+
describe("update event", function () {
|
126
|
+
it("throws on undefined args", function () {
|
127
|
+
array.push(23);
|
128
|
+
array.push('a string');
|
129
|
+
|
130
|
+
expect(function () {
|
131
|
+
binder('update', undefined);
|
132
|
+
}).toThrow(new Error('undefined arguments'));
|
133
|
+
|
134
|
+
refuteEmpty(array);
|
135
|
+
});
|
136
|
+
|
137
|
+
it("throws on undefined entry", function () {
|
138
|
+
array.push(23);
|
139
|
+
array.push('a string');
|
140
|
+
|
141
|
+
expect(function () {
|
142
|
+
binder('update', {
|
143
|
+
id: 12,
|
144
|
+
entry: undefined
|
145
|
+
});
|
146
|
+
}).toThrow(new Error('undefined entry'));
|
147
|
+
|
148
|
+
assertEqual([23, 'a string'], array);
|
149
|
+
});
|
150
|
+
|
151
|
+
it("throws on undefined id", function () {
|
152
|
+
array.push(23);
|
153
|
+
array.push('a string');
|
154
|
+
|
155
|
+
expect(function () {
|
156
|
+
binder('update', {
|
157
|
+
id: undefined,
|
158
|
+
entry: {}
|
159
|
+
});
|
160
|
+
}).toThrow(new Error('undefined id'));
|
161
|
+
|
162
|
+
assertEqual([23, 'a string'], array);
|
163
|
+
});
|
164
|
+
|
165
|
+
it("maps collection arg 'entry' to a replace at given id", function () {
|
166
|
+
array.push({
|
167
|
+
id: 1,
|
168
|
+
entry: {'a': 13}
|
169
|
+
});
|
170
|
+
array.push({
|
171
|
+
id: 2,
|
172
|
+
entry: {'b': 42}
|
173
|
+
});
|
174
|
+
|
175
|
+
binder('update', {
|
176
|
+
id: 2,
|
177
|
+
entry: {id: 2, entry: {'x': 12}}
|
178
|
+
});
|
179
|
+
|
180
|
+
assertEqual([
|
181
|
+
{id: 1, entry: {'a': 13}}, {id: 2, entry: {'x': 12}}
|
182
|
+
], array)
|
183
|
+
});
|
184
|
+
|
185
|
+
it("throws if id was not found", function() {
|
186
|
+
array.push({
|
187
|
+
id: 1,
|
188
|
+
entry: {'a': 13}
|
189
|
+
});
|
190
|
+
array.push({
|
191
|
+
id: 2,
|
192
|
+
entry: {'b': 42}
|
193
|
+
});
|
194
|
+
|
195
|
+
expect(function () {
|
196
|
+
binder('update', {
|
197
|
+
id: 3,
|
198
|
+
entry: {}
|
199
|
+
});
|
200
|
+
}).toThrow(new Error('unknown id: 3'));
|
201
|
+
|
202
|
+
assertEqual([
|
203
|
+
{id: 1, entry: {'a': 13}}, {id: 2, entry: {'b': 42}}
|
204
|
+
], array)
|
205
|
+
});
|
206
|
+
});
|
207
|
+
|
208
|
+
describe("remove event", function () {
|
209
|
+
it("throws on undefined args", function () {
|
210
|
+
array.push(23);
|
211
|
+
array.push('a string');
|
212
|
+
|
213
|
+
expect(function () {
|
214
|
+
binder('remove', undefined);
|
215
|
+
}).toThrow(new Error('undefined arguments'));
|
216
|
+
|
217
|
+
refuteEmpty(array);
|
218
|
+
});
|
219
|
+
|
220
|
+
it("throws on undefined id", function () {
|
221
|
+
array.push(23);
|
222
|
+
array.push('a string');
|
223
|
+
|
224
|
+
expect(function () {
|
225
|
+
binder('remove', {
|
226
|
+
id: undefined
|
227
|
+
});
|
228
|
+
}).toThrow(new Error('undefined id'));
|
229
|
+
|
230
|
+
assertEqual([23, 'a string'], array);
|
231
|
+
});
|
232
|
+
|
233
|
+
it("removes entry at given id", function () {
|
234
|
+
array.push({
|
235
|
+
id: 1,
|
236
|
+
entry: {'a': 13}
|
237
|
+
});
|
238
|
+
array.push({
|
239
|
+
id: 2,
|
240
|
+
entry: {'b': 42}
|
241
|
+
});
|
242
|
+
|
243
|
+
binder('remove', {
|
244
|
+
id: 1,
|
245
|
+
});
|
246
|
+
|
247
|
+
assertEqual([
|
248
|
+
{id: 2, entry: {'b': 42}}
|
249
|
+
], array)
|
250
|
+
});
|
251
|
+
|
252
|
+
it("throws if id was not found", function() {
|
253
|
+
array.push({
|
254
|
+
id: 1,
|
255
|
+
entry: {'a': 13}
|
256
|
+
});
|
257
|
+
array.push({
|
258
|
+
id: 2,
|
259
|
+
entry: {'b': 42}
|
260
|
+
});
|
261
|
+
|
262
|
+
expect(function () {
|
263
|
+
binder('remove', {
|
264
|
+
id: 3
|
265
|
+
});
|
266
|
+
}).toThrow(new Error('unknown id: 3'));
|
267
|
+
|
268
|
+
assertEqual([
|
269
|
+
{id: 1, entry: {'a': 13}}, {id: 2, entry: {'b': 42}}
|
270
|
+
], array)
|
271
|
+
});
|
272
|
+
});
|
273
|
+
});
|
@@ -0,0 +1,23 @@
|
|
1
|
+
function assertEqual(expected, actual) {
|
2
|
+
expect(expected).toEqual(actual);
|
3
|
+
}
|
4
|
+
|
5
|
+
function refuteEqual(expected, actual) {
|
6
|
+
expect(expected).toNotEqual(actual);
|
7
|
+
}
|
8
|
+
|
9
|
+
function assertEmpty(expected) {
|
10
|
+
expect(expected.length).toEqual(0);
|
11
|
+
}
|
12
|
+
|
13
|
+
function refuteEmpty(expected) {
|
14
|
+
expect(expected.length).toBeGreaterThan(0);
|
15
|
+
}
|
16
|
+
|
17
|
+
function assertNull(value) {
|
18
|
+
expect(value).toBeNull();
|
19
|
+
}
|
20
|
+
|
21
|
+
function refuteNull(value) {
|
22
|
+
expect(value).not.toBeNull();
|
23
|
+
}
|
metadata
ADDED
@@ -0,0 +1,130 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: transistor
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jakob Holderbaum
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-05-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: jasmine
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: jslint-v8
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: jake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
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
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: gem-this
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description:
|
84
|
+
email: jakob@featurefabrik.de
|
85
|
+
executables: []
|
86
|
+
extensions: []
|
87
|
+
extra_rdoc_files:
|
88
|
+
- README.md
|
89
|
+
files:
|
90
|
+
- Gemfile.lock
|
91
|
+
- index.html
|
92
|
+
- Rakefile
|
93
|
+
- Gemfile
|
94
|
+
- faye-browser.js
|
95
|
+
- README.md
|
96
|
+
- jake.yml
|
97
|
+
- spec/javascripts/helpers/AssertHelpers.js
|
98
|
+
- spec/javascripts/TransistorBinderSpec.js
|
99
|
+
- spec/javascripts/support/jasmine.yml
|
100
|
+
- lib/transistor/binder.js
|
101
|
+
- lib/transistor/control.js
|
102
|
+
- lib/transistor/radio.js
|
103
|
+
- lib/vendor/jsonp.js
|
104
|
+
- lib/vendor/faye-browser-min.js
|
105
|
+
homepage: http://featurefabrik.com
|
106
|
+
licenses: []
|
107
|
+
metadata: {}
|
108
|
+
post_install_message:
|
109
|
+
rdoc_options:
|
110
|
+
- --main
|
111
|
+
- README.md
|
112
|
+
require_paths:
|
113
|
+
- lib
|
114
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - '>='
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - '>='
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
124
|
+
requirements: []
|
125
|
+
rubyforge_project:
|
126
|
+
rubygems_version: 2.0.3
|
127
|
+
signing_key:
|
128
|
+
specification_version: 4
|
129
|
+
summary: Client for the radiotower.io service
|
130
|
+
test_files: []
|