ende 0.4.5 → 0.4.6
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 +4 -4
- data/lib/assets/javascripts/aura/extensions/devise.js.coffee +0 -2
- data/lib/assets/javascripts/aura/extensions/platform.js.coffee +3 -0
- data/lib/assets/javascripts/aura/extensions/rivets.js.coffee +17 -1
- data/lib/assets/javascripts/aura/extensions/routes.js.coffee +8 -7
- data/lib/assets/javascripts/aura/extensions/states.js.coffee +13 -1
- data/lib/assets/javascripts/aura/extensions/widget/eventable.js.coffee +4 -2
- data/lib/assets/javascripts/config/load_components.js.coffee +19 -12
- data/lib/assets/javascripts/ende.js.coffee +33 -12
- data/lib/ende/version.rb +1 -1
- data/vendor/assets/components/build.css +111 -0
- data/vendor/assets/components/ende_build.js +160 -41
- data/vendor/components/indefinido-indemma/build/development.js +3 -118
- data/vendor/components/indefinido-indemma/build/release.js +39 -4170
- data/vendor/components/indefinido-indemma/build/test.js +3 -118
- data/vendor/components/indefinido-indemma/lib/record/associable.js +10 -2
- data/vendor/components/indefinido-indemma/lib/record/restfulable.js +26 -15
- data/vendor/components/indefinido-indemma/lib/record.js +3 -1
- data/vendor/components/indefinido-indemma/src/lib/record/associable.coffee +15 -1
- data/vendor/components/indefinido-indemma/src/lib/record/restfulable.coffee +37 -12
- data/vendor/components/indefinido-indemma/src/lib/record.coffee +3 -1
- data/vendor/components/indefinido-observable/.gitignore +15 -0
- data/vendor/components/indefinido-observable/.ruby-gemset +1 -0
- data/vendor/components/indefinido-observable/.ruby-version +1 -0
- data/vendor/components/indefinido-observable/Gemfile +13 -0
- data/vendor/components/indefinido-observable/Guardfile +39 -0
- data/vendor/components/indefinido-observable/History.md +0 -0
- data/vendor/components/indefinido-observable/Readme.md +116 -0
- data/vendor/components/indefinido-observable/build/build.js +14798 -0
- data/vendor/components/indefinido-observable/build/development.js +339 -0
- data/vendor/components/indefinido-observable/build/release.js +14937 -0
- data/vendor/components/indefinido-observable/build/test.js +339 -0
- data/vendor/components/indefinido-observable/component.json +5 -1
- data/vendor/components/indefinido-observable/components/chaijs-chai/component.json +46 -0
- data/vendor/components/indefinido-observable/components/chaijs-chai/index.js +1 -0
- data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/assertion.js +132 -0
- data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/core/assertions.js +1270 -0
- data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/error.js +60 -0
- data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/interface/assert.js +1060 -0
- data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/interface/expect.js +12 -0
- data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/interface/should.js +76 -0
- data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/addChainableMethod.js +94 -0
- data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/addMethod.js +37 -0
- data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/addProperty.js +40 -0
- data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/eql.js +124 -0
- data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/flag.js +32 -0
- data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/getActual.js +19 -0
- data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/getEnumerableProperties.js +25 -0
- data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/getMessage.js +49 -0
- data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/getName.js +20 -0
- data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/getPathValue.js +102 -0
- data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/getProperties.js +35 -0
- data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/index.js +108 -0
- data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/inspect.js +316 -0
- data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/objDisplay.js +48 -0
- data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/overwriteMethod.js +51 -0
- data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/overwriteProperty.js +54 -0
- data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/test.js +26 -0
- data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/transferFlags.js +44 -0
- data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/type.js +45 -0
- data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai.js +79 -0
- data/vendor/components/indefinido-observable/components/component-jquery/component.json +14 -0
- data/vendor/components/indefinido-observable/components/component-jquery/index.js +9601 -0
- data/vendor/components/indefinido-observable/components/kapit-observe-shim/component.json +11 -0
- data/vendor/components/indefinido-observable/components/kapit-observe-utils/component.json +13 -0
- data/vendor/components/indefinido-observable/karma.conf.js +92 -0
- data/vendor/components/indefinido-observable/lib/adapters/rivets.js +3 -1
- data/vendor/components/indefinido-observable/lib/observable.js +47 -13
- data/vendor/components/indefinido-observable/spec/legacy/observable_spec.js +126 -0
- data/vendor/components/indefinido-observable/spec/observable_spec.js +92 -0
- data/vendor/components/indefinido-observable/spec/spec_helper.js +8 -0
- data/vendor/components/indefinido-observable/spec/vendor/accessors_spec.js +63 -0
- data/vendor/components/indefinido-observable/src/lib/adapters/rivets.js.coffee +15 -0
- data/vendor/components/indefinido-observable/src/spec/legacy/observable_spec.coffee +132 -0
- data/vendor/components/indefinido-observable/src/spec/observable_spec.coffee +85 -0
- data/vendor/components/indefinido-observable/src/spec/spec_helper.coffee +5 -0
- data/vendor/components/indefinido-observable/src/spec/vendor/accessors_spec.coffee +59 -0
- data/vendor/components/indefinido-observable/vendor/shims/accessors.js +71 -9
- data/vendor/components/indefinido-observable/vendor/spec/boot.js +104 -0
- data/vendor/components/indefinido-observable/vendor/spec/jasmine.js +2054 -0
- metadata +58 -2
@@ -0,0 +1,11 @@
|
|
1
|
+
{
|
2
|
+
"name": "observe-shim",
|
3
|
+
"version": "0.1.1",
|
4
|
+
"main": "lib/observe-shim.js",
|
5
|
+
"devDependencies": {
|
6
|
+
"mocha": "~1.8.x",
|
7
|
+
"expect": "~0.2.0",
|
8
|
+
"sinon": "http://sinonjs.org/releases/sinon-1.6.0.js"
|
9
|
+
},
|
10
|
+
"repo": "https://raw.github.com/kapit/observe-shim"
|
11
|
+
}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
{
|
2
|
+
"name": "observe-utils",
|
3
|
+
"version": "0.1.0",
|
4
|
+
"main": "lib/observe-utils.js",
|
5
|
+
"devDependencies": {
|
6
|
+
"expect": "~0.2.0",
|
7
|
+
"sinon": "http://sinonjs.org/releases/sinon-1.6.0.js",
|
8
|
+
"observe-shim": "https://github.com/KapIT/observe-shim.git",
|
9
|
+
"mocha": "~1.8.1",
|
10
|
+
"es5-shim": "~2.0.8"
|
11
|
+
},
|
12
|
+
"repo": "https://raw.github.com/kapit/observe-utils"
|
13
|
+
}
|
@@ -0,0 +1,92 @@
|
|
1
|
+
// Karma configuration
|
2
|
+
|
3
|
+
module.exports = function(config) {
|
4
|
+
config.set({
|
5
|
+
// base path, that will be used to resolve files and exclude
|
6
|
+
basePath: '',
|
7
|
+
|
8
|
+
// list of files / patterns to load in the browser
|
9
|
+
files: [
|
10
|
+
|
11
|
+
// Test environment
|
12
|
+
//MOCHA, Switch to mocha when not testing ie
|
13
|
+
//MOCHA_ADAPTER,
|
14
|
+
JASMINE,
|
15
|
+
JASMINE_ADAPTER,
|
16
|
+
'components/cjohansen-sinon/sinon.js',
|
17
|
+
|
18
|
+
// Test dependencies
|
19
|
+
'build/test.js',
|
20
|
+
|
21
|
+
// Test Source files
|
22
|
+
'spec/spec_helper.js',
|
23
|
+
'spec/**/*.js'
|
24
|
+
],
|
25
|
+
|
26
|
+
|
27
|
+
// list of files to exclude
|
28
|
+
exclude: [
|
29
|
+
'spec/coverage'
|
30
|
+
],
|
31
|
+
|
32
|
+
// Custom frameworks
|
33
|
+
frameworks: ['jasmine'],
|
34
|
+
|
35
|
+
|
36
|
+
// test results reporter to use
|
37
|
+
// possible values: 'dots', 'progress', 'junit'
|
38
|
+
reporters: ['progress'], // , 'coverage'],
|
39
|
+
|
40
|
+
|
41
|
+
// web server port
|
42
|
+
port: 9876,
|
43
|
+
|
44
|
+
|
45
|
+
// cli runner port
|
46
|
+
runnerPort: 9100,
|
47
|
+
|
48
|
+
|
49
|
+
// enable / disable colors in the output (reporters and logs)
|
50
|
+
colors: true,
|
51
|
+
|
52
|
+
|
53
|
+
// level of logging
|
54
|
+
// possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG
|
55
|
+
logLevel: LOG_INFO,
|
56
|
+
|
57
|
+
|
58
|
+
// enable / disable watching file and executing tests whenever any file changes
|
59
|
+
autoWatch: true,
|
60
|
+
|
61
|
+
|
62
|
+
// Start these browsers, currently available:
|
63
|
+
// - Chrome
|
64
|
+
// - ChromeCanary
|
65
|
+
// - Firefox
|
66
|
+
// - Opera
|
67
|
+
// - Safari (only Mac)
|
68
|
+
// - PhantomJS
|
69
|
+
// - IE (only Windows)
|
70
|
+
browsers: ['Chrome'],
|
71
|
+
|
72
|
+
|
73
|
+
// If browser does not capture in given timeout [ms], kill it
|
74
|
+
captureTimeout: 60000,
|
75
|
+
|
76
|
+
|
77
|
+
// Continuous Integration mode
|
78
|
+
// if true, it capture browsers, run tests and exit
|
79
|
+
singleRun: false,
|
80
|
+
|
81
|
+
// Coverage preprocessors
|
82
|
+
// preprocessors: {
|
83
|
+
// '**/lib/*.js': 'coverage'
|
84
|
+
// },
|
85
|
+
|
86
|
+
// Converage configuration
|
87
|
+
coverageReporter: {
|
88
|
+
type : 'html',
|
89
|
+
dir : 'spec/coverage'
|
90
|
+
}
|
91
|
+
});
|
92
|
+
}
|
@@ -3,7 +3,9 @@ exports.adapter = {
|
|
3
3
|
if (record == null) {
|
4
4
|
throw new TypeError('observable.adapters.rivets.subscribe: No record provided for subscription');
|
5
5
|
}
|
6
|
-
|
6
|
+
if (attribute_path) {
|
7
|
+
return record.subscribe(attribute_path, callback);
|
8
|
+
}
|
7
9
|
},
|
8
10
|
unsubscribe: function(record, attribute_path, callback) {
|
9
11
|
if (record == null) {
|
@@ -7,11 +7,12 @@ if (!Array.prototype.indexOf) require('../vendor/shims/array.indexOf');
|
|
7
7
|
|
8
8
|
// Object.defineProperty (for ie5+)
|
9
9
|
if (typeof require != 'undefined') {
|
10
|
-
require('../vendor/shims/accessors.js');
|
11
|
-
|
12
10
|
// __lookup*__ and __define*__ for browsers with defineProperty support
|
13
11
|
// TODO Figure out why gives an infinity loop
|
14
12
|
require('../vendor/shims/accessors-legacy.js');
|
13
|
+
|
14
|
+
// Creates Object.defineProperty
|
15
|
+
require('../vendor/shims/accessors.js');
|
15
16
|
}
|
16
17
|
|
17
18
|
// Require Dependencies
|
@@ -88,9 +89,10 @@ mixin = {
|
|
88
89
|
if (requiresDomElement) {
|
89
90
|
|
90
91
|
observable = function (object) {
|
92
|
+
var fix;
|
91
93
|
|
92
94
|
// observable() or observable(object)
|
93
|
-
|
95
|
+
if (this.document && this.location) {
|
94
96
|
if (!object) {
|
95
97
|
object = {};
|
96
98
|
}
|
@@ -105,15 +107,28 @@ if (requiresDomElement) {
|
|
105
107
|
}
|
106
108
|
}
|
107
109
|
|
110
|
+
// TODO better documentation
|
108
111
|
if (!jQuery.isReady) throw new Error('observable.call: For compatibility reasons, observable can only be called when dom is loaded.');
|
109
|
-
var fix = document.createElement('fix');
|
110
112
|
|
111
|
-
if
|
112
|
-
|
113
|
+
// Create dom element if object isn't one
|
114
|
+
if (!(typeof object.nodeName === 'string')) {
|
115
|
+
fix = document.createElement('fix');
|
116
|
+
|
117
|
+
if (!jQuery.isReady) $(function () {document.body.appendChild(fix);});
|
118
|
+
else document.body.appendChild(fix);
|
113
119
|
|
114
|
-
|
120
|
+
// Replace object with dom node
|
121
|
+
object = fix;
|
122
|
+
}
|
123
|
+
|
124
|
+
// Observe element if it is not observed
|
125
|
+
// TODO remove jquery dependency
|
126
|
+
if (!object.observed) {
|
127
|
+
generator.observable_for(object);
|
128
|
+
object = $.extend(object, mixin);
|
129
|
+
}
|
115
130
|
|
116
|
-
return
|
131
|
+
return object;
|
117
132
|
};
|
118
133
|
|
119
134
|
var ignores = document.createElement('fix'), fix_ignores = [], property;
|
@@ -151,9 +166,8 @@ if (requiresDomElement) {
|
|
151
166
|
observable.ignores = [];
|
152
167
|
}
|
153
168
|
|
154
|
-
|
155
169
|
observable.unobserve = function (object) {
|
156
|
-
var name, value, subname;
|
170
|
+
var name, value, subname, unobserved = {};
|
157
171
|
|
158
172
|
// TODO remove root setter and root getter and callbacks from
|
159
173
|
// callback thread
|
@@ -166,6 +180,7 @@ observable.unobserve = function (object) {
|
|
166
180
|
// Remove array properties overrides
|
167
181
|
for (name in object) {
|
168
182
|
value = object[name];
|
183
|
+
|
169
184
|
if ($.type(value) == 'array') {
|
170
185
|
delete value.thread;
|
171
186
|
delete value.object;
|
@@ -177,8 +192,16 @@ observable.unobserve = function (object) {
|
|
177
192
|
}
|
178
193
|
}
|
179
194
|
|
195
|
+
for (name in object) {
|
196
|
+
// TODO put Array.indexOf as a dependency
|
197
|
+
if (observable.ignores && observable.ignores.indexOf(name) == -1) {
|
198
|
+
unobserved[name] = object[name];
|
199
|
+
}
|
200
|
+
}
|
201
|
+
|
180
202
|
delete object.observed;
|
181
|
-
|
203
|
+
|
204
|
+
return unobserved;
|
182
205
|
};
|
183
206
|
|
184
207
|
check = function (keypath, value) {
|
@@ -190,7 +213,8 @@ check = function (keypath, value) {
|
|
190
213
|
};
|
191
214
|
|
192
215
|
generator = {
|
193
|
-
|
216
|
+
// TODO pass object as parameter
|
217
|
+
observe: function (keypath, callback) {
|
194
218
|
return Object.defineProperty(this, keypath, {
|
195
219
|
get: generator.getter.call(this, keypath),
|
196
220
|
set: generator.setter.call(this, keypath, callback),
|
@@ -199,11 +223,21 @@ generator = {
|
|
199
223
|
},
|
200
224
|
|
201
225
|
observable_for: function (object) {
|
202
|
-
|
226
|
+
Object.defineProperty(object, 'observed', {
|
203
227
|
configurable: true,
|
204
228
|
enumerable: false,
|
205
229
|
value: {}
|
206
230
|
});
|
231
|
+
|
232
|
+
// TODO call the current object.toJSON after this method
|
233
|
+
return Object.defineProperty(object, 'toJSON', {
|
234
|
+
enumerable: false,
|
235
|
+
value: function () {
|
236
|
+
// TODO remove underscore dependency
|
237
|
+
return observable.unobserve(_.omit(this, observable.ignores));
|
238
|
+
// old_to_json()
|
239
|
+
}
|
240
|
+
});
|
207
241
|
},
|
208
242
|
|
209
243
|
// TODO improve readability
|
@@ -0,0 +1,126 @@
|
|
1
|
+
var $, observable, root;
|
2
|
+
|
3
|
+
observable = require('observable').mixin;
|
4
|
+
|
5
|
+
root = typeof exports !== "undefined" && exports !== null ? exports : window;
|
6
|
+
|
7
|
+
$ = require('jquery');
|
8
|
+
|
9
|
+
describe('observable #()', function() {
|
10
|
+
var object;
|
11
|
+
|
12
|
+
object = null;
|
13
|
+
beforeEach(function() {
|
14
|
+
return object = {
|
15
|
+
property: 'value'
|
16
|
+
};
|
17
|
+
});
|
18
|
+
it('should not have observed property', function() {
|
19
|
+
return expect(object.observed).toBeUndefined();
|
20
|
+
});
|
21
|
+
xit('should let element unsubscribe to property', function() {});
|
22
|
+
describe('#subscribe', function() {
|
23
|
+
var called;
|
24
|
+
|
25
|
+
called = null;
|
26
|
+
beforeEach(function() {
|
27
|
+
object = observable({});
|
28
|
+
called = false;
|
29
|
+
return true;
|
30
|
+
});
|
31
|
+
it('should subscribe to property', function() {
|
32
|
+
var spy;
|
33
|
+
|
34
|
+
spy = sinon.spy();
|
35
|
+
object.subscribe('other', spy);
|
36
|
+
object.other = 'mafagafo';
|
37
|
+
return expect(spy.called).toBe(true);
|
38
|
+
});
|
39
|
+
it('should let multiple function subscriptions to property', function() {
|
40
|
+
var also_also_called, also_called;
|
41
|
+
|
42
|
+
also_called = false;
|
43
|
+
also_also_called = false;
|
44
|
+
object.subscribe('other', function() {
|
45
|
+
return called = true;
|
46
|
+
});
|
47
|
+
object.subscribe('other', function() {
|
48
|
+
return also_called = true;
|
49
|
+
});
|
50
|
+
object.subscribe('other', function() {
|
51
|
+
return also_also_called = true;
|
52
|
+
});
|
53
|
+
object.other = 'mafagafo';
|
54
|
+
expect(called).toBe(true);
|
55
|
+
return expect(also_called).toBe(true);
|
56
|
+
});
|
57
|
+
it('should handle truth comparisons well', function() {
|
58
|
+
var block_called, spy;
|
59
|
+
|
60
|
+
spy = sinon.spy;
|
61
|
+
block_called = false;
|
62
|
+
object.invert = true;
|
63
|
+
object.truthy = true;
|
64
|
+
object.falsey = false;
|
65
|
+
object.subscribe('truthy', spy);
|
66
|
+
object.subscribe('falsey', spy);
|
67
|
+
object.subscribe('invert', spy);
|
68
|
+
block_called = false;
|
69
|
+
if (object.truthy) {
|
70
|
+
block_called = true;
|
71
|
+
}
|
72
|
+
expect(block_called).toBe(true);
|
73
|
+
block_called = false;
|
74
|
+
if (!object.falsey) {
|
75
|
+
block_called = true;
|
76
|
+
}
|
77
|
+
expect(block_called).toBe(true);
|
78
|
+
block_called = false;
|
79
|
+
if (object.invert) {
|
80
|
+
block_called = true;
|
81
|
+
}
|
82
|
+
object.invert = false;
|
83
|
+
block_called = false;
|
84
|
+
if (object.invert === false) {
|
85
|
+
block_called = true;
|
86
|
+
}
|
87
|
+
return expect(block_called).toBe(true);
|
88
|
+
});
|
89
|
+
describe('subscribes to properties of type array', function() {
|
90
|
+
it('should observe objects added to array', function() {
|
91
|
+
var friend, spy;
|
92
|
+
|
93
|
+
spy = sinon.spy();
|
94
|
+
friend = {
|
95
|
+
domo: 1
|
96
|
+
};
|
97
|
+
object.friends = [];
|
98
|
+
object.subscribe('friends', function() {});
|
99
|
+
object.friends = [friend];
|
100
|
+
friend = object.friends[0];
|
101
|
+
expect(friend.domo).toBeDefined();
|
102
|
+
expect(friend.observed).toBeDefined();
|
103
|
+
friend.subscribe('domo', spy);
|
104
|
+
friend.domo = 2;
|
105
|
+
return expect(spy.callCount).toBe(1);
|
106
|
+
});
|
107
|
+
it('should override native methods');
|
108
|
+
return it('should preserve array bindings when setting new array', function() {
|
109
|
+
var spy;
|
110
|
+
|
111
|
+
spy = sinon.spy();
|
112
|
+
object.friends = [];
|
113
|
+
object.subscribe('friends', spy);
|
114
|
+
object.friends.push(1);
|
115
|
+
object.friends = [];
|
116
|
+
object.friends.push(2);
|
117
|
+
expect(object.friends.length).toBe(1);
|
118
|
+
return expect(spy.callCount).toBe(3);
|
119
|
+
});
|
120
|
+
});
|
121
|
+
return it('should create a observed property', function() {});
|
122
|
+
});
|
123
|
+
return xdescribe('#publish', function() {
|
124
|
+
return xit('should let element publish to property', function() {});
|
125
|
+
});
|
126
|
+
});
|
@@ -0,0 +1,92 @@
|
|
1
|
+
var observable, root;
|
2
|
+
|
3
|
+
observable = require('observable').mixin;
|
4
|
+
|
5
|
+
root = typeof exports !== "undefined" && exports !== null ? exports : window;
|
6
|
+
|
7
|
+
describe('observable #()', function() {
|
8
|
+
var object;
|
9
|
+
|
10
|
+
if (!root.should) {
|
11
|
+
return;
|
12
|
+
}
|
13
|
+
object = null;
|
14
|
+
beforeEach(function() {
|
15
|
+
return object = {
|
16
|
+
property: 'value'
|
17
|
+
};
|
18
|
+
});
|
19
|
+
it('should not have observed property', function() {
|
20
|
+
return object.should.not.have.property('observed');
|
21
|
+
});
|
22
|
+
xit('should let element unsubscribe to property', function() {});
|
23
|
+
describe('#subscribe', function() {
|
24
|
+
var called;
|
25
|
+
|
26
|
+
called = null;
|
27
|
+
beforeEach(function() {
|
28
|
+
object = observable({});
|
29
|
+
called = false;
|
30
|
+
return true;
|
31
|
+
});
|
32
|
+
it('should subscribe to property', function() {
|
33
|
+
var spy;
|
34
|
+
|
35
|
+
spy = sinon.spy();
|
36
|
+
object.subscribe('other', spy);
|
37
|
+
object.other = 'mafagafo';
|
38
|
+
return spy.called.should.be["true"];
|
39
|
+
});
|
40
|
+
it('should let multiple function subscriptions to property', function() {
|
41
|
+
var also_called;
|
42
|
+
|
43
|
+
also_called = false;
|
44
|
+
object.subscribe('other', function() {
|
45
|
+
return called = true;
|
46
|
+
});
|
47
|
+
object.subscribe('other', function() {
|
48
|
+
return also_called = true;
|
49
|
+
});
|
50
|
+
object.other = 'mafagafo';
|
51
|
+
called.should.be["true"];
|
52
|
+
return also_called.should.be["true"];
|
53
|
+
});
|
54
|
+
describe('subscribes to properties of type array', function() {
|
55
|
+
it('should observe objects added to array', function() {
|
56
|
+
var friend, spy;
|
57
|
+
|
58
|
+
spy = sinon.spy();
|
59
|
+
friend = {
|
60
|
+
domo: 1
|
61
|
+
};
|
62
|
+
object.friends = [];
|
63
|
+
object.subscribe('friends', function() {});
|
64
|
+
object.friends = [friend];
|
65
|
+
object.friends[0].should.be.eq(friend);
|
66
|
+
friend.should.have.property('observed');
|
67
|
+
friend.subscribe('domo', spy);
|
68
|
+
friend.domo = 2;
|
69
|
+
return spy.callCount.should.be.eq(1);
|
70
|
+
});
|
71
|
+
xit('should override native methods');
|
72
|
+
return it('should preserve array bindings when setting new array', function() {
|
73
|
+
var spy;
|
74
|
+
|
75
|
+
spy = sinon.spy();
|
76
|
+
object.friends = [];
|
77
|
+
object.subscribe('friends', spy);
|
78
|
+
object.friends.push(1);
|
79
|
+
object.friends = [];
|
80
|
+
object.friends.push(2);
|
81
|
+
object.friends.length.should.be.eq(1);
|
82
|
+
return spy.callCount.should.be.eq(3);
|
83
|
+
});
|
84
|
+
});
|
85
|
+
return it('should create a observed property', function() {
|
86
|
+
return object.should.have.property('observed');
|
87
|
+
});
|
88
|
+
});
|
89
|
+
return xdescribe('#publish', function() {
|
90
|
+
return xit('should let element publish to property', function() {});
|
91
|
+
});
|
92
|
+
});
|
@@ -0,0 +1,63 @@
|
|
1
|
+
var $;
|
2
|
+
|
3
|
+
require('observable/vendor/shims/accessors.js');
|
4
|
+
|
5
|
+
$ = require('jquery');
|
6
|
+
|
7
|
+
describe('Object #defineProperty', function() {
|
8
|
+
describe('on dom elements', function() {
|
9
|
+
var object, spy;
|
10
|
+
|
11
|
+
spy = object = null;
|
12
|
+
beforeEach(function() {
|
13
|
+
object = document.createElement('domo');
|
14
|
+
document.body.appendChild(object);
|
15
|
+
return spy = sinon.spy();
|
16
|
+
});
|
17
|
+
it('should define property', function(done) {
|
18
|
+
return Object.defineProperty(object, 'kun', {});
|
19
|
+
});
|
20
|
+
it('should define property getter', function(done) {
|
21
|
+
var getter;
|
22
|
+
|
23
|
+
getter = sinon.stub().returns(42);
|
24
|
+
Object.defineProperty(object, 'kun', {
|
25
|
+
get: getter
|
26
|
+
});
|
27
|
+
expect(object.kun + 1).toBe(43);
|
28
|
+
return expect(getter.called).toBe(true);
|
29
|
+
});
|
30
|
+
return it('should define property setter', function(done) {
|
31
|
+
Object.defineProperty(object, 'kun', {
|
32
|
+
set: spy
|
33
|
+
});
|
34
|
+
object.kun = 10;
|
35
|
+
return expect(spy.calledWith(10)).toBe(true);
|
36
|
+
});
|
37
|
+
});
|
38
|
+
return describe('off dom elements', function() {
|
39
|
+
beforeEach(function() {
|
40
|
+
this.object = {};
|
41
|
+
return this.spy = sinon.spy();
|
42
|
+
});
|
43
|
+
it('should not define property setter', function(done) {
|
44
|
+
var _this = this;
|
45
|
+
|
46
|
+
return expect(function() {
|
47
|
+
return Object.defineProperty(_this.object, 'kun', {
|
48
|
+
set: _this.spy
|
49
|
+
});
|
50
|
+
}).toThrow();
|
51
|
+
});
|
52
|
+
return it('should define property getter', function(done) {
|
53
|
+
var getter;
|
54
|
+
|
55
|
+
getter = sinon.stub().returns(42);
|
56
|
+
Object.defineProperty(this.object, 'kun', {
|
57
|
+
get: getter
|
58
|
+
});
|
59
|
+
expect(this.object.kun + 1).toBe(43);
|
60
|
+
return expect(getter.called).toBe(true);
|
61
|
+
});
|
62
|
+
});
|
63
|
+
});
|
@@ -0,0 +1,15 @@
|
|
1
|
+
exports.adapter =
|
2
|
+
subscribe: (record, attribute_path, callback) ->
|
3
|
+
throw new TypeError 'observable.adapters.rivets.subscribe: No record provided for subscription' unless record?
|
4
|
+
# TODO parse aura widget attributes options, remove, add as a
|
5
|
+
# comentary, and let rivets bindings flow, and remove the if check
|
6
|
+
record.subscribe attribute_path, callback if attribute_path
|
7
|
+
unsubscribe: (record, attribute_path, callback) ->
|
8
|
+
throw new TypeError 'observable.adapters.rivets.unsubscribe: No record provided for subscription' unless record?
|
9
|
+
record.unsubscribe attribute_path, callback
|
10
|
+
read: (record, attribute_path) ->
|
11
|
+
throw new TypeError 'observable.adapters.rivets.read: No record provided for subscription' unless record?
|
12
|
+
record[attribute_path]
|
13
|
+
publish: (record, attribute_path, value) ->
|
14
|
+
throw new TypeError 'observable.adapters.rivets.publish: No record provided for subscription' unless record?
|
15
|
+
record[attribute_path] = value
|
@@ -0,0 +1,132 @@
|
|
1
|
+
observable = require('observable').mixin
|
2
|
+
root = exports ? window
|
3
|
+
$ = require 'jquery'
|
4
|
+
|
5
|
+
describe 'observable #()', ->
|
6
|
+
|
7
|
+
object = null
|
8
|
+
|
9
|
+
beforeEach ->
|
10
|
+
object = property: 'value'
|
11
|
+
|
12
|
+
it 'should not have observed property', ->
|
13
|
+
expect(object.observed).toBeUndefined()
|
14
|
+
|
15
|
+
xit 'should let element unsubscribe to property', ->
|
16
|
+
|
17
|
+
describe '#subscribe', ->
|
18
|
+
called = null
|
19
|
+
|
20
|
+
beforeEach ->
|
21
|
+
object = observable({})
|
22
|
+
called = false
|
23
|
+
true
|
24
|
+
|
25
|
+
it 'should subscribe to property', ->
|
26
|
+
spy = sinon.spy()
|
27
|
+
object.subscribe 'other', spy
|
28
|
+
object.other = 'mafagafo'
|
29
|
+
|
30
|
+
expect(spy.called).toBe true
|
31
|
+
|
32
|
+
|
33
|
+
it 'should let multiple function subscriptions to property', ->
|
34
|
+
also_called = false
|
35
|
+
also_also_called = false
|
36
|
+
|
37
|
+
object.subscribe 'other', -> called = true
|
38
|
+
|
39
|
+
object.subscribe 'other', -> also_called = true
|
40
|
+
|
41
|
+
object.subscribe 'other', -> also_also_called = true
|
42
|
+
|
43
|
+
object.other = 'mafagafo'
|
44
|
+
|
45
|
+
expect(called).toBe true
|
46
|
+
expect(also_called).toBe true
|
47
|
+
|
48
|
+
it 'should handle truth comparisons well', ->
|
49
|
+
spy = sinon.spy
|
50
|
+
block_called = false
|
51
|
+
object.invert = true
|
52
|
+
object.truthy = true
|
53
|
+
object.falsey = false
|
54
|
+
|
55
|
+
object.subscribe 'truthy', spy
|
56
|
+
object.subscribe 'falsey' , spy
|
57
|
+
object.subscribe 'invert', spy
|
58
|
+
|
59
|
+
block_called = false
|
60
|
+
if object.truthy
|
61
|
+
# dump 'truthy'
|
62
|
+
block_called = true
|
63
|
+
|
64
|
+
expect(block_called).toBe true
|
65
|
+
|
66
|
+
block_called = false
|
67
|
+
# dump (object.falsey + '') == 'false'
|
68
|
+
unless object.falsey
|
69
|
+
# dump 'falsey'
|
70
|
+
block_called = true
|
71
|
+
|
72
|
+
expect(block_called).toBe true
|
73
|
+
|
74
|
+
block_called = false
|
75
|
+
if object.invert
|
76
|
+
# dump 'invert'
|
77
|
+
block_called = true
|
78
|
+
|
79
|
+
object.invert = false
|
80
|
+
|
81
|
+
block_called = false
|
82
|
+
if object.invert == false
|
83
|
+
# dump 'inverted'
|
84
|
+
block_called = true
|
85
|
+
|
86
|
+
expect(block_called).toBe true
|
87
|
+
|
88
|
+
|
89
|
+
describe 'subscribes to properties of type array', ->
|
90
|
+
it 'should observe objects added to array', ->
|
91
|
+
spy = sinon.spy()
|
92
|
+
friend = {domo: 1}
|
93
|
+
|
94
|
+
# TODO implement a one time setter to solve this
|
95
|
+
# Specifically on array types
|
96
|
+
# property must be an array before subscribing
|
97
|
+
object.friends = []
|
98
|
+
|
99
|
+
# Remember, you must subscribe to new properties to
|
100
|
+
# turn then into observable ones
|
101
|
+
object.subscribe 'friends', ->
|
102
|
+
|
103
|
+
object.friends = [friend]
|
104
|
+
friend = object.friends[0]
|
105
|
+
|
106
|
+
expect(friend.domo ).toBeDefined()
|
107
|
+
expect(friend.observed).toBeDefined()
|
108
|
+
|
109
|
+
friend.subscribe 'domo', spy
|
110
|
+
friend.domo = 2
|
111
|
+
expect(spy.callCount).toBe 1
|
112
|
+
|
113
|
+
it 'should override native methods'
|
114
|
+
|
115
|
+
it 'should preserve array bindings when setting new array', ->
|
116
|
+
spy = sinon.spy()
|
117
|
+
object.friends = []
|
118
|
+
object.subscribe 'friends', spy
|
119
|
+
|
120
|
+
object.friends.push 1
|
121
|
+
object.friends = []
|
122
|
+
object.friends.push 2
|
123
|
+
|
124
|
+
expect(object.friends.length).toBe 1
|
125
|
+
expect(spy.callCount).toBe 3
|
126
|
+
|
127
|
+
it 'should create a observed property', ->
|
128
|
+
# object.should.have.property 'observed'
|
129
|
+
|
130
|
+
xdescribe '#publish', ->
|
131
|
+
|
132
|
+
xit 'should let element publish to property', ->
|