volt 0.8.14 → 0.8.15
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/.gitignore +1 -1
- data/Readme.md +8 -2
- data/VERSION +1 -1
- data/app/volt/controllers/notices_controller.rb +1 -1
- data/app/volt/models/user.rb +2 -2
- data/app/volt/tasks/live_query/live_query_pool.rb +1 -1
- data/app/volt/tasks/query_tasks.rb +1 -1
- data/app/volt/tasks/store_tasks.rb +1 -1
- data/app/volt/tasks/user_tasks.rb +2 -2
- data/lib/volt/boot.rb +2 -2
- data/lib/volt/cli/asset_compile.rb +31 -27
- data/lib/volt/cli.rb +64 -65
- data/lib/volt/config.rb +25 -23
- data/lib/volt/console.rb +17 -16
- data/lib/volt/controllers/model_controller.rb +82 -80
- data/lib/volt/data_stores/data_store.rb +2 -2
- data/lib/volt/data_stores/mongo_driver.rb +2 -2
- data/lib/volt/extra_core/inflections.rb +2 -2
- data/lib/volt/extra_core/inflector/inflections.rb +185 -183
- data/lib/volt/extra_core/inflector/methods.rb +50 -48
- data/lib/volt/extra_core/string.rb +2 -2
- data/lib/volt/models/array_model.rb +93 -92
- data/lib/volt/models/cursor.rb +3 -2
- data/lib/volt/models/model.rb +248 -251
- data/lib/volt/models/model_hash_behaviour.rb +44 -44
- data/lib/volt/models/model_helpers.rb +38 -36
- data/lib/volt/models/model_state.rb +16 -17
- data/lib/volt/models/model_wrapper.rb +25 -24
- data/lib/volt/models/persistors/array_store.rb +145 -143
- data/lib/volt/models/persistors/base.rb +18 -16
- data/lib/volt/models/persistors/flash.rb +24 -22
- data/lib/volt/models/persistors/local_store.rb +46 -44
- data/lib/volt/models/persistors/model_identity_map.rb +10 -8
- data/lib/volt/models/persistors/model_store.rb +76 -76
- data/lib/volt/models/persistors/params.rb +19 -17
- data/lib/volt/models/persistors/query/query_listener.rb +65 -63
- data/lib/volt/models/persistors/query/query_listener_pool.rb +12 -10
- data/lib/volt/models/persistors/store.rb +28 -28
- data/lib/volt/models/persistors/store_factory.rb +12 -10
- data/lib/volt/models/persistors/store_state.rb +33 -31
- data/lib/volt/models/url.rb +96 -104
- data/lib/volt/models/validations.rb +56 -54
- data/lib/volt/models/validators/length_validator.rb +24 -22
- data/lib/volt/models/validators/presence_validator.rb +14 -12
- data/lib/volt/page/bindings/attribute_binding.rb +106 -106
- data/lib/volt/page/bindings/base_binding.rb +23 -21
- data/lib/volt/page/bindings/component_binding.rb +3 -1
- data/lib/volt/page/bindings/content_binding.rb +34 -34
- data/lib/volt/page/bindings/each_binding.rb +113 -113
- data/lib/volt/page/bindings/event_binding.rb +38 -34
- data/lib/volt/page/bindings/if_binding.rb +56 -54
- data/lib/volt/page/bindings/template_binding/grouped_controllers.rb +24 -22
- data/lib/volt/page/bindings/template_binding.rb +182 -185
- data/lib/volt/page/channel.rb +79 -77
- data/lib/volt/page/channel_stub.rb +29 -27
- data/lib/volt/page/document.rb +6 -5
- data/lib/volt/page/document_events.rb +54 -52
- data/lib/volt/page/page.rb +139 -138
- data/lib/volt/page/string_template_renderer.rb +36 -36
- data/lib/volt/page/sub_context.rb +26 -25
- data/lib/volt/page/targets/attribute_section.rb +27 -25
- data/lib/volt/page/targets/attribute_target.rb +7 -6
- data/lib/volt/page/targets/base_section.rb +27 -26
- data/lib/volt/page/targets/binding_document/base_node.rb +3 -1
- data/lib/volt/page/targets/binding_document/component_node.rb +85 -82
- data/lib/volt/page/targets/binding_document/html_node.rb +11 -9
- data/lib/volt/page/targets/dom_section.rb +78 -77
- data/lib/volt/page/targets/dom_target.rb +8 -6
- data/lib/volt/page/targets/dom_template.rb +90 -88
- data/lib/volt/page/targets/helpers/comment_searchers.rb +51 -49
- data/lib/volt/page/tasks.rb +59 -57
- data/lib/volt/page/template_renderer.rb +17 -14
- data/lib/volt/page/url_tracker.rb +26 -24
- data/lib/volt/reactive/computation.rb +87 -88
- data/lib/volt/reactive/dependency.rb +30 -28
- data/lib/volt/reactive/eventable.rb +64 -62
- data/lib/volt/reactive/hash_dependency.rb +25 -23
- data/lib/volt/reactive/reactive_accessors.rb +34 -32
- data/lib/volt/reactive/reactive_array.rb +162 -162
- data/lib/volt/reactive/reactive_hash.rb +37 -35
- data/lib/volt/router/routes.rb +99 -101
- data/lib/volt/server/component_handler.rb +20 -21
- data/lib/volt/server/component_templates.rb +72 -70
- data/lib/volt/server/html_parser/attribute_scope.rb +109 -99
- data/lib/volt/server/html_parser/each_scope.rb +17 -16
- data/lib/volt/server/html_parser/if_view_scope.rb +51 -49
- data/lib/volt/server/html_parser/sandlebars_parser.rb +184 -177
- data/lib/volt/server/html_parser/textarea_scope.rb +24 -22
- data/lib/volt/server/html_parser/view_handler.rb +66 -65
- data/lib/volt/server/html_parser/view_parser.rb +23 -21
- data/lib/volt/server/html_parser/view_scope.rb +142 -141
- data/lib/volt/server/rack/asset_files.rb +81 -79
- data/lib/volt/server/rack/component_code.rb +17 -15
- data/lib/volt/server/rack/component_html_renderer.rb +14 -12
- data/lib/volt/server/rack/component_paths.rb +72 -71
- data/lib/volt/server/rack/index_files.rb +36 -39
- data/lib/volt/server/rack/opal_files.rb +43 -41
- data/lib/volt/server/rack/source_map_server.rb +23 -21
- data/lib/volt/server/socket_connection_handler.rb +46 -45
- data/lib/volt/server/socket_connection_handler_stub.rb +21 -19
- data/lib/volt/server.rb +60 -58
- data/lib/volt/spec/setup.rb +3 -3
- data/lib/volt/tasks/dispatcher.rb +24 -23
- data/lib/volt/tasks/task_handler.rb +35 -33
- data/lib/volt/utils/ejson.rb +8 -6
- data/lib/volt/utils/generic_counting_pool.rb +33 -31
- data/lib/volt/utils/generic_pool.rb +73 -70
- data/lib/volt/utils/local_storage.rb +42 -38
- data/lib/volt/volt/environment.rb +1 -1
- data/lib/volt.rb +44 -42
- data/spec/apps/kitchen_sink/app/main/assets/css/todos.css +28 -0
- data/spec/apps/kitchen_sink/app/main/config/routes.rb +1 -0
- data/spec/apps/kitchen_sink/app/main/controllers/main_controller.rb +2 -2
- data/spec/apps/kitchen_sink/app/main/controllers/todos_controller.rb +17 -0
- data/spec/apps/kitchen_sink/app/main/views/main/main.html +1 -0
- data/spec/apps/kitchen_sink/app/main/views/todos/index.html +24 -0
- data/spec/apps/kitchen_sink/config.ru +1 -1
- data/spec/controllers/reactive_accessors_spec.rb +5 -5
- data/spec/extra_core/inflector_spec.rb +2 -2
- data/spec/integration/list_spec.rb +68 -0
- data/spec/models/model_spec.rb +57 -57
- data/spec/models/persistors/params_spec.rb +6 -6
- data/spec/models/persistors/store_spec.rb +7 -7
- data/spec/models/validations_spec.rb +3 -3
- data/spec/page/bindings/content_binding_spec.rb +7 -7
- data/spec/page/bindings/template_binding_spec.rb +4 -5
- data/spec/page/sub_context_spec.rb +2 -2
- data/spec/reactive/computation_spec.rb +10 -10
- data/spec/reactive/dependency_spec.rb +2 -2
- data/spec/reactive/eventable_spec.rb +4 -4
- data/spec/reactive/reactive_array_spec.rb +13 -13
- data/spec/router/routes_spec.rb +5 -5
- data/spec/server/html_parser/sandlebars_parser_spec.rb +9 -9
- data/spec/server/html_parser/view_parser_spec.rb +27 -27
- data/spec/server/rack/asset_files_spec.rb +5 -5
- data/spec/server/rack/component_paths_spec.rb +2 -2
- data/spec/tasks/live_query_spec.rb +2 -2
- data/spec/tasks/query_tasks.rb +1 -1
- data/spec/tasks/query_tracker_spec.rb +1 -1
- data/spec/templates/targets/binding_document/component_node_spec.rb +2 -2
- data/spec/utils/generic_counting_pool_spec.rb +2 -2
- data/spec/utils/generic_pool_spec.rb +2 -2
- data/templates/component/controllers/main_controller.rb +1 -1
- data/templates/model/model.rb.tt +2 -2
- data/templates/newgem/app/newgem/controllers/main_controller.rb.tt +2 -2
- data/templates/project/app/main/controllers/main_controller.rb +1 -1
- data/templates/project/config.ru +1 -1
- metadata +10 -3
- data/app/volt/assets/js/vertxbus.js +0 -216
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2011-2012 the original author or authors.
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
var vertx = vertx || {};
|
|
18
|
-
|
|
19
|
-
!function(factory) {
|
|
20
|
-
if (typeof define === "function" && define.amd) {
|
|
21
|
-
// Expose as an AMD module with SockJS dependency.
|
|
22
|
-
// "vertxbus" and "sockjs" names are used because
|
|
23
|
-
// AMD module names are derived from file names.
|
|
24
|
-
define("vertxbus", ["sockjs"], factory);
|
|
25
|
-
} else {
|
|
26
|
-
// No AMD-compliant loader
|
|
27
|
-
factory(SockJS);
|
|
28
|
-
}
|
|
29
|
-
}(function(SockJS) {
|
|
30
|
-
|
|
31
|
-
vertx.EventBus = function(url, options) {
|
|
32
|
-
|
|
33
|
-
var that = this;
|
|
34
|
-
var sockJSConn = new SockJS(url, undefined, options);
|
|
35
|
-
var handlerMap = {};
|
|
36
|
-
var replyHandlers = {};
|
|
37
|
-
var state = vertx.EventBus.CONNECTING;
|
|
38
|
-
var sessionID = null;
|
|
39
|
-
var pingTimerID = null;
|
|
40
|
-
|
|
41
|
-
that.onopen = null;
|
|
42
|
-
that.onclose = null;
|
|
43
|
-
|
|
44
|
-
that.login = function(username, password, replyHandler) {
|
|
45
|
-
sendOrPub("send", 'vertx.basicauthmanager.login', {username: username, password: password}, function(reply) {
|
|
46
|
-
if (reply.status === 'ok') {
|
|
47
|
-
that.sessionID = reply.sessionID;
|
|
48
|
-
}
|
|
49
|
-
if (replyHandler) {
|
|
50
|
-
delete reply.sessionID;
|
|
51
|
-
replyHandler(reply)
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
that.send = function(address, message, replyHandler) {
|
|
57
|
-
sendOrPub("send", address, message, replyHandler)
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
that.publish = function(address, message, replyHandler) {
|
|
61
|
-
sendOrPub("publish", address, message, replyHandler)
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
that.registerHandler = function(address, handler) {
|
|
65
|
-
checkSpecified("address", 'string', address);
|
|
66
|
-
checkSpecified("handler", 'function', handler);
|
|
67
|
-
checkOpen();
|
|
68
|
-
var handlers = handlerMap[address];
|
|
69
|
-
if (!handlers) {
|
|
70
|
-
handlers = [handler];
|
|
71
|
-
handlerMap[address] = handlers;
|
|
72
|
-
// First handler for this address so we should register the connection
|
|
73
|
-
var msg = { type : "register",
|
|
74
|
-
address: address };
|
|
75
|
-
sockJSConn.send(JSON.stringify(msg));
|
|
76
|
-
} else {
|
|
77
|
-
handlers[handlers.length] = handler;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
that.unregisterHandler = function(address, handler) {
|
|
82
|
-
checkSpecified("address", 'string', address);
|
|
83
|
-
checkSpecified("handler", 'function', handler);
|
|
84
|
-
checkOpen();
|
|
85
|
-
var handlers = handlerMap[address];
|
|
86
|
-
if (handlers) {
|
|
87
|
-
var idx = handlers.indexOf(handler);
|
|
88
|
-
if (idx != -1) handlers.splice(idx, 1);
|
|
89
|
-
if (handlers.length == 0) {
|
|
90
|
-
// No more local handlers so we should unregister the connection
|
|
91
|
-
|
|
92
|
-
var msg = { type : "unregister",
|
|
93
|
-
address: address};
|
|
94
|
-
sockJSConn.send(JSON.stringify(msg));
|
|
95
|
-
delete handlerMap[address];
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
that.close = function() {
|
|
101
|
-
checkOpen();
|
|
102
|
-
if (pingTimerID) clearInterval(pingTimerID);
|
|
103
|
-
state = vertx.EventBus.CLOSING;
|
|
104
|
-
sockJSConn.close();
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
that.readyState = function() {
|
|
108
|
-
return state;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
sockJSConn.onopen = function() {
|
|
112
|
-
// Send the first ping then send a ping every 5 seconds
|
|
113
|
-
sendPing();
|
|
114
|
-
pingTimerID = setInterval(sendPing, 5000);
|
|
115
|
-
state = vertx.EventBus.OPEN;
|
|
116
|
-
if (that.onopen) {
|
|
117
|
-
that.onopen();
|
|
118
|
-
}
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
sockJSConn.onclose = function() {
|
|
122
|
-
state = vertx.EventBus.CLOSED;
|
|
123
|
-
if (that.onclose) {
|
|
124
|
-
that.onclose();
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
sockJSConn.onmessage = function(e) {
|
|
129
|
-
var msg = e.data;
|
|
130
|
-
var json = JSON.parse(msg);
|
|
131
|
-
var body = json.body;
|
|
132
|
-
var replyAddress = json.replyAddress;
|
|
133
|
-
var address = json.address;
|
|
134
|
-
var replyHandler;
|
|
135
|
-
if (replyAddress) {
|
|
136
|
-
replyHandler = function(reply, replyHandler) {
|
|
137
|
-
// Send back reply
|
|
138
|
-
that.send(replyAddress, reply, replyHandler);
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
var handlers = handlerMap[address];
|
|
142
|
-
if (handlers) {
|
|
143
|
-
// We make a copy since the handler might get unregistered from within the
|
|
144
|
-
// handler itself, which would screw up our iteration
|
|
145
|
-
var copy = handlers.slice(0);
|
|
146
|
-
for (var i = 0; i < copy.length; i++) {
|
|
147
|
-
copy[i](body, replyHandler);
|
|
148
|
-
}
|
|
149
|
-
} else {
|
|
150
|
-
// Might be a reply message
|
|
151
|
-
var handler = replyHandlers[address];
|
|
152
|
-
if (handler) {
|
|
153
|
-
delete replyHandlers[address];
|
|
154
|
-
handler(body, replyHandler);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
function sendPing() {
|
|
160
|
-
var msg = {
|
|
161
|
-
type: "ping"
|
|
162
|
-
}
|
|
163
|
-
sockJSConn.send(JSON.stringify(msg));
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
function sendOrPub(sendOrPub, address, message, replyHandler) {
|
|
167
|
-
checkSpecified("address", 'string', address);
|
|
168
|
-
checkSpecified("replyHandler", 'function', replyHandler, true);
|
|
169
|
-
checkOpen();
|
|
170
|
-
var envelope = { type : sendOrPub,
|
|
171
|
-
address: address,
|
|
172
|
-
body: message };
|
|
173
|
-
if (that.sessionID) {
|
|
174
|
-
envelope.sessionID = that.sessionID;
|
|
175
|
-
}
|
|
176
|
-
if (replyHandler) {
|
|
177
|
-
var replyAddress = makeUUID();
|
|
178
|
-
envelope.replyAddress = replyAddress;
|
|
179
|
-
replyHandlers[replyAddress] = replyHandler;
|
|
180
|
-
}
|
|
181
|
-
var str = JSON.stringify(envelope);
|
|
182
|
-
sockJSConn.send(str);
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
function checkOpen() {
|
|
186
|
-
if (state != vertx.EventBus.OPEN) {
|
|
187
|
-
throw new Error('INVALID_STATE_ERR');
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
function checkSpecified(paramName, paramType, param, optional) {
|
|
192
|
-
if (!optional && !param) {
|
|
193
|
-
throw new Error("Parameter " + paramName + " must be specified");
|
|
194
|
-
}
|
|
195
|
-
if (param && typeof param != paramType) {
|
|
196
|
-
throw new Error("Parameter " + paramName + " must be of type " + paramType);
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
function isFunction(obj) {
|
|
201
|
-
return !!(obj && obj.constructor && obj.call && obj.apply);
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
function makeUUID(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx"
|
|
205
|
-
.replace(/[xy]/g,function(a,b){return b=Math.random()*16,(a=="y"?b&3|8:b|0).toString(16)})}
|
|
206
|
-
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
vertx.EventBus.CONNECTING = 0;
|
|
210
|
-
vertx.EventBus.OPEN = 1;
|
|
211
|
-
vertx.EventBus.CLOSING = 2;
|
|
212
|
-
vertx.EventBus.CLOSED = 3;
|
|
213
|
-
|
|
214
|
-
return vertx.EventBus;
|
|
215
|
-
|
|
216
|
-
});
|