volt 0.8.8 → 0.8.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -0
- data/Readme.md +2 -1036
- data/VERSION +1 -1
- data/app/volt/models/user.rb +5 -0
- data/app/volt/tasks/query_tasks.rb +3 -3
- data/app/volt/tasks/store_tasks.rb +17 -15
- data/app/volt/tasks/user_tasks.rb +6 -0
- data/lib/volt/cli.rb +9 -0
- data/lib/volt/extra_core/string.rb +10 -2
- data/lib/volt/models/array_model.rb +0 -1
- data/lib/volt/models/model.rb +45 -28
- data/lib/volt/models/model_hash_behaviour.rb +16 -4
- data/lib/volt/models/model_helpers.rb +4 -2
- data/lib/volt/models/model_wrapper.rb +2 -1
- data/lib/volt/models/persistors/array_store.rb +6 -6
- data/lib/volt/models/persistors/local_store.rb +1 -1
- data/lib/volt/models/persistors/model_store.rb +3 -3
- data/lib/volt/models/persistors/query/query_listener.rb +6 -4
- data/lib/volt/models/persistors/query/query_listener_pool.rb +9 -0
- data/lib/volt/models/persistors/store.rb +1 -0
- data/lib/volt/models/url.rb +20 -10
- data/lib/volt/page/bindings/template_binding.rb +7 -1
- data/lib/volt/page/page.rb +3 -3
- data/lib/volt/page/tasks.rb +20 -19
- data/lib/volt/reactive/reactive_array.rb +44 -0
- data/lib/volt/router/routes.rb +5 -0
- data/lib/volt/server.rb +3 -1
- data/lib/volt/server/component_templates.rb +7 -1
- data/lib/volt/server/html_parser/attribute_scope.rb +1 -1
- data/lib/volt/server/rack/component_paths.rb +1 -10
- data/lib/volt/server/socket_connection_handler.rb +3 -0
- data/lib/volt/tasks/dispatcher.rb +3 -7
- data/lib/volt/tasks/task_handler.rb +41 -0
- data/spec/integration/bindings_spec.rb +1 -1
- data/spec/models/model_spec.rb +32 -32
- data/spec/models/persistors/params_spec.rb +1 -1
- data/spec/router/routes_spec.rb +4 -4
- data/templates/model/model.rb.tt +3 -0
- metadata +6 -2
data/spec/models/model_spec.rb
CHANGED
@@ -178,8 +178,8 @@ describe Model do
|
|
178
178
|
it "should add doubly nested arrays" do
|
179
179
|
model = Model.new
|
180
180
|
|
181
|
-
model._items << {
|
182
|
-
model._items[0]._lists << {
|
181
|
+
model._items << {name: 'Cool', lists: []}
|
182
|
+
model._items[0]._lists << {name: 'worked'}
|
183
183
|
expect(model._items[0]._lists[0]._name).to eq('worked')
|
184
184
|
end
|
185
185
|
|
@@ -202,7 +202,7 @@ describe Model do
|
|
202
202
|
a = Model.new
|
203
203
|
|
204
204
|
count = 0
|
205
|
-
-> { a._blue && a._blue.respond_to?(:
|
205
|
+
-> { a._blue && a._blue.respond_to?(:green) && a._blue._green ; count += 1 }.watch!
|
206
206
|
expect(count).to eq(1)
|
207
207
|
|
208
208
|
a._blue._green = 5
|
@@ -215,7 +215,7 @@ describe Model do
|
|
215
215
|
Computation.flush!
|
216
216
|
expect(count).to eq(3)
|
217
217
|
|
218
|
-
a._blue = {
|
218
|
+
a._blue = {green: 50}
|
219
219
|
expect(a._blue._green).to eq(50)
|
220
220
|
Computation.flush!
|
221
221
|
expect(count).to eq(4)
|
@@ -232,7 +232,7 @@ describe Model do
|
|
232
232
|
Computation.flush!
|
233
233
|
expect(count).to eq(2)
|
234
234
|
|
235
|
-
a.delete(:
|
235
|
+
a.delete(:blue)
|
236
236
|
Computation.flush!
|
237
237
|
expect(count).to eq(3)
|
238
238
|
end
|
@@ -240,7 +240,7 @@ describe Model do
|
|
240
240
|
it "should let you append nested hashes" do
|
241
241
|
a = Model.new
|
242
242
|
|
243
|
-
a._items << {
|
243
|
+
a._items << {name: {text: 'Name'}}
|
244
244
|
|
245
245
|
expect(a._items[0]._name._text).to eq('Name')
|
246
246
|
end
|
@@ -248,13 +248,13 @@ describe Model do
|
|
248
248
|
|
249
249
|
it "should not call added too many times" do
|
250
250
|
a = Model.new
|
251
|
-
a.
|
251
|
+
a._lists << 1
|
252
252
|
|
253
253
|
count = 0
|
254
|
-
a.
|
254
|
+
a._lists.on('added') { count += 1 }
|
255
255
|
expect(count).to eq(0)
|
256
256
|
|
257
|
-
a.
|
257
|
+
a._lists << 2
|
258
258
|
expect(count).to eq(1)
|
259
259
|
end
|
260
260
|
|
@@ -275,13 +275,13 @@ describe Model do
|
|
275
275
|
describe "paths" do
|
276
276
|
it "should store the path" do
|
277
277
|
a = Model.new
|
278
|
-
expect(a._test.path).to eq([:
|
278
|
+
expect(a._test.path).to eq([:test])
|
279
279
|
a._test = {_name: 'Yes'}
|
280
|
-
expect(a._test.path).to eq([:
|
280
|
+
expect(a._test.path).to eq([:test])
|
281
281
|
|
282
282
|
a._items << {_name: 'Yes'}
|
283
|
-
expect(a._items.path).to eq([:
|
284
|
-
expect(a._items[0].path).to eq([:
|
283
|
+
expect(a._items.path).to eq([:items])
|
284
|
+
expect(a._items[0].path).to eq([:items, :[]])
|
285
285
|
end
|
286
286
|
|
287
287
|
it "should store the paths when assigned" do
|
@@ -289,17 +289,17 @@ describe Model do
|
|
289
289
|
|
290
290
|
a._items = [{_name: 'Cool'}]
|
291
291
|
|
292
|
-
expect(a._items.path).to eq([:
|
293
|
-
expect(a._items[0].path).to eq([:
|
292
|
+
expect(a._items.path).to eq([:items])
|
293
|
+
expect(a._items[0].path).to eq([:items, :[]])
|
294
294
|
end
|
295
295
|
|
296
296
|
it "should handle nested paths" do
|
297
297
|
a = Model.new
|
298
298
|
|
299
|
-
a._items << {
|
299
|
+
a._items << {name: 'Cool', lists: [{name: 'One'}, {name: 'Two'}]}
|
300
300
|
|
301
|
-
expect(a._items[0]._lists.path).to eq([:
|
302
|
-
expect(a._items[0]._lists[1].path).to eq([:
|
301
|
+
expect(a._items[0]._lists.path).to eq([:items, :[], :lists])
|
302
|
+
expect(a._items[0]._lists[1].path).to eq([:items, :[], :lists, :[]])
|
303
303
|
end
|
304
304
|
|
305
305
|
it "should trigger added when added" do
|
@@ -337,9 +337,9 @@ describe Model do
|
|
337
337
|
it "should delete from an ArrayModel" do
|
338
338
|
array = ArrayModel.new([])
|
339
339
|
|
340
|
-
array << {
|
341
|
-
array << {
|
342
|
-
array << {
|
340
|
+
array << {name: 'One'}
|
341
|
+
array << {name: 'Two'}
|
342
|
+
array << {name: 'Three'}
|
343
343
|
|
344
344
|
expect(array.size).to eq(3)
|
345
345
|
|
@@ -362,18 +362,18 @@ describe Model do
|
|
362
362
|
|
363
363
|
it "should convert to a hash, and unwrap all of the way down" do
|
364
364
|
a = Model.new
|
365
|
-
a._items << {
|
366
|
-
a._items << {
|
365
|
+
a._items << {name: 'Test1', other: {time: 'Now'}}
|
366
|
+
a._items << {name: 'Test2', other: {time: 'Later'}}
|
367
367
|
|
368
368
|
item1 = a._items[0].to_h
|
369
|
-
expect(item1[:
|
370
|
-
expect(item1[:
|
369
|
+
expect(item1[:name]).to eq('Test1')
|
370
|
+
expect(item1[:other][:time]).to eq('Now')
|
371
371
|
|
372
372
|
all_items = a._items.to_a
|
373
373
|
|
374
374
|
a = [
|
375
|
-
{:
|
376
|
-
{:
|
375
|
+
{:name => "Test1", :other => {:time => "Now"}},
|
376
|
+
{:name => "Test2", :other => {:time => "Later"}}
|
377
377
|
]
|
378
378
|
expect(all_items).to eq(a)
|
379
379
|
end
|
@@ -386,25 +386,25 @@ describe Model do
|
|
386
386
|
|
387
387
|
it "should set the model path" do
|
388
388
|
@model._object._name = 'Test'
|
389
|
-
expect(@model._object.path).to eq([:
|
389
|
+
expect(@model._object.path).to eq([:object])
|
390
390
|
end
|
391
391
|
|
392
392
|
it "should set the model path for a sub array" do
|
393
393
|
@model._items << {_name: 'Bob'}
|
394
|
-
expect(@model._items.path).to eq([:
|
395
|
-
expect(@model._items[0].path).to eq([:
|
394
|
+
expect(@model._items.path).to eq([:items])
|
395
|
+
expect(@model._items[0].path).to eq([:items, :[]])
|
396
396
|
end
|
397
397
|
|
398
398
|
it "should set the model path for sub sub arrays" do
|
399
399
|
@model._lists << {_name: 'List 1', _items: []}
|
400
|
-
expect(@model._lists[0]._items.path).to eq([:
|
400
|
+
expect(@model._lists[0]._items.path).to eq([:lists, :[], :items])
|
401
401
|
end
|
402
402
|
|
403
403
|
it "should update the path when added from a model instance to a collection" do
|
404
404
|
test_item = TestItem.new
|
405
405
|
|
406
406
|
@model._items << test_item
|
407
|
-
expect(@model._items[0].path).to eq([:
|
407
|
+
expect(@model._items[0].path).to eq([:items, :[]])
|
408
408
|
end
|
409
409
|
end
|
410
410
|
|
@@ -8,7 +8,7 @@ describe Persistors::Params do
|
|
8
8
|
|
9
9
|
expect(a._test._cool.persistor.class).to eq(Persistors::Params)
|
10
10
|
|
11
|
-
a._items << {
|
11
|
+
a._items << {name: 'Test'}
|
12
12
|
|
13
13
|
expect(a._items.persistor.class).to eq(Persistors::Params)
|
14
14
|
expect(a._items[0].persistor.class).to eq(Persistors::Params)
|
data/spec/router/routes_spec.rb
CHANGED
@@ -100,16 +100,16 @@ describe Routes do
|
|
100
100
|
get '/login/{{ _name }}/user/{{ _id }}', _view: 'login', _action: 'user'
|
101
101
|
end
|
102
102
|
|
103
|
-
url, params = @routes.params_to_url({
|
103
|
+
url, params = @routes.params_to_url({view: 'blog/show', id: '55'})
|
104
104
|
expect(url).to eq('/blog/55')
|
105
105
|
expect(params).to eq({})
|
106
106
|
|
107
107
|
|
108
|
-
url, params = @routes.params_to_url({
|
108
|
+
url, params = @routes.params_to_url({view: 'blog/edit', id: '100'})
|
109
109
|
expect(url).to eq('/blog/100/edit')
|
110
110
|
expect(params).to eq({})
|
111
111
|
|
112
|
-
url, params = @routes.params_to_url({
|
112
|
+
url, params = @routes.params_to_url({view: 'blog/edit', id: '100', other: 'should_pass'})
|
113
113
|
expect(url).to eq('/blog/100/edit')
|
114
114
|
expect(params).to eq({_other: 'should_pass'})
|
115
115
|
end
|
@@ -152,7 +152,7 @@ describe Routes do
|
|
152
152
|
get '/blog', _controller: 'blog'
|
153
153
|
end
|
154
154
|
|
155
|
-
path, cleaned_params = @routes.params_to_url(params)
|
155
|
+
path, cleaned_params = @routes.params_to_url(params.to_h)
|
156
156
|
expect(path).to eq('/blog')
|
157
157
|
expect(cleaned_params).to eq({_index: '5'})
|
158
158
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: volt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Stout
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -358,12 +358,14 @@ files:
|
|
358
358
|
- app/volt/assets/js/vertxbus.js
|
359
359
|
- app/volt/config/dependencies.rb
|
360
360
|
- app/volt/controllers/notices_controller.rb
|
361
|
+
- app/volt/models/user.rb
|
361
362
|
- app/volt/tasks/live_query/data_store.rb
|
362
363
|
- app/volt/tasks/live_query/live_query.rb
|
363
364
|
- app/volt/tasks/live_query/live_query_pool.rb
|
364
365
|
- app/volt/tasks/live_query/query_tracker.rb
|
365
366
|
- app/volt/tasks/query_tasks.rb
|
366
367
|
- app/volt/tasks/store_tasks.rb
|
368
|
+
- app/volt/tasks/user_tasks.rb
|
367
369
|
- app/volt/views/notices/index.html
|
368
370
|
- bin/volt
|
369
371
|
- docs/FAQ.md
|
@@ -484,6 +486,7 @@ files:
|
|
484
486
|
- lib/volt/spec/setup.rb
|
485
487
|
- lib/volt/store/mongo.rb
|
486
488
|
- lib/volt/tasks/dispatcher.rb
|
489
|
+
- lib/volt/tasks/task_handler.rb
|
487
490
|
- lib/volt/utils/ejson.rb
|
488
491
|
- lib/volt/utils/generic_counting_pool.rb
|
489
492
|
- lib/volt/utils/generic_pool.rb
|
@@ -537,6 +540,7 @@ files:
|
|
537
540
|
- spec/utils/generic_counting_pool_spec.rb
|
538
541
|
- spec/utils/generic_pool_spec.rb
|
539
542
|
- templates/.gitignore
|
543
|
+
- templates/model/model.rb.tt
|
540
544
|
- templates/newgem/Gemfile.tt
|
541
545
|
- templates/newgem/LICENSE.txt.tt
|
542
546
|
- templates/newgem/README.md.tt
|