volt 0.5.18 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Readme.md +14 -0
- data/VERSION +1 -1
- data/app/volt/controllers/notices_controller.rb +9 -0
- data/app/volt/tasks/live_query/data_store.rb +12 -0
- data/app/volt/tasks/live_query/live_query.rb +86 -0
- data/app/volt/tasks/live_query/live_query_pool.rb +36 -0
- data/app/volt/tasks/live_query/query_tracker.rb +95 -0
- data/app/volt/tasks/query_tasks.rb +57 -0
- data/app/volt/tasks/store_tasks.rb +4 -17
- data/lib/volt.rb +2 -0
- data/lib/volt/console.rb +1 -1
- data/lib/volt/controllers/model_controller.rb +4 -0
- data/lib/volt/extra_core/array.rb +9 -0
- data/lib/volt/extra_core/extra_core.rb +1 -0
- data/lib/volt/extra_core/hash.rb +11 -0
- data/lib/volt/extra_core/object.rb +4 -0
- data/lib/volt/models/array_model.rb +56 -0
- data/lib/volt/models/model.rb +6 -11
- data/lib/volt/models/model_helpers.rb +12 -0
- data/lib/volt/models/persistors/array_store.rb +120 -21
- data/lib/volt/models/persistors/model_identity_map.rb +12 -0
- data/lib/volt/models/persistors/model_store.rb +20 -60
- data/lib/volt/models/persistors/query/query_listener.rb +87 -0
- data/lib/volt/models/persistors/query/query_listener_pool.rb +9 -0
- data/lib/volt/models/persistors/store.rb +11 -13
- data/lib/volt/models/url.rb +1 -1
- data/lib/volt/page/bindings/attribute_binding.rb +2 -2
- data/lib/volt/page/bindings/base_binding.rb +13 -1
- data/lib/volt/page/bindings/component_binding.rb +1 -1
- data/lib/volt/page/bindings/content_binding.rb +2 -2
- data/lib/volt/page/bindings/each_binding.rb +25 -21
- data/lib/volt/page/bindings/event_binding.rb +4 -6
- data/lib/volt/page/bindings/if_binding.rb +4 -5
- data/lib/volt/page/bindings/template_binding.rb +4 -4
- data/lib/volt/page/channel.rb +0 -1
- data/lib/volt/page/document.rb +7 -0
- data/lib/volt/page/page.rb +4 -4
- data/lib/volt/page/reactive_template.rb +2 -2
- data/lib/volt/page/targets/dom_section.rb +5 -0
- data/lib/volt/page/tasks.rb +10 -40
- data/lib/volt/page/template_renderer.rb +4 -4
- data/lib/volt/reactive/events.rb +14 -0
- data/lib/volt/reactive/reactive_array.rb +17 -7
- data/lib/volt/reactive/reactive_value.rb +65 -1
- data/lib/volt/server.rb +1 -1
- data/lib/volt/server/if_binding_setup.rb +3 -1
- data/lib/volt/server/socket_connection_handler.rb +7 -5
- data/lib/volt/server/template_parser.rb +7 -7
- data/lib/volt/tasks/dispatcher.rb +3 -0
- data/lib/volt/utils/ejson.rb +9 -0
- data/lib/volt/utils/generic_counting_pool.rb +44 -0
- data/lib/volt/utils/generic_pool.rb +88 -0
- data/spec/models/reactive_array_spec.rb +43 -0
- data/spec/models/reactive_generator_spec.rb +58 -0
- data/spec/models/reactive_value_spec.rb +6 -0
- data/spec/page/bindings/content_binding_spec.rb +36 -0
- data/spec/spec_helper.rb +13 -12
- data/spec/tasks/live_query_spec.rb +20 -0
- data/spec/tasks/query_tasks.rb +10 -0
- data/spec/tasks/query_tracker_spec.rb +120 -0
- data/spec/templates/template_binding_spec.rb +16 -10
- data/spec/utils/generic_counting_pool_spec.rb +36 -0
- data/spec/utils/generic_pool_spec.rb +50 -0
- metadata +29 -5
- data/app/volt/tasks/channel_tasks.rb +0 -55
- data/spec/tasks/channel_tasks_spec.rb +0 -74
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.
|
4
|
+
version: 0.6.0
|
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-02-
|
11
|
+
date: 2014-02-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -327,7 +327,11 @@ files:
|
|
327
327
|
- app/volt/assets/js/sockjs-0.2.1.min.js
|
328
328
|
- app/volt/config/dependencies.rb
|
329
329
|
- app/volt/controllers/notices_controller.rb
|
330
|
-
- app/volt/tasks/
|
330
|
+
- app/volt/tasks/live_query/data_store.rb
|
331
|
+
- app/volt/tasks/live_query/live_query.rb
|
332
|
+
- app/volt/tasks/live_query/live_query_pool.rb
|
333
|
+
- app/volt/tasks/live_query/query_tracker.rb
|
334
|
+
- app/volt/tasks/query_tasks.rb
|
331
335
|
- app/volt/tasks/store_tasks.rb
|
332
336
|
- app/volt/views/notices/index.html
|
333
337
|
- bin/volt
|
@@ -343,6 +347,7 @@ files:
|
|
343
347
|
- lib/volt/extra_core/array.rb
|
344
348
|
- lib/volt/extra_core/blank.rb
|
345
349
|
- lib/volt/extra_core/extra_core.rb
|
350
|
+
- lib/volt/extra_core/hash.rb
|
346
351
|
- lib/volt/extra_core/numeric.rb
|
347
352
|
- lib/volt/extra_core/object.rb
|
348
353
|
- lib/volt/extra_core/string.rb
|
@@ -360,8 +365,11 @@ files:
|
|
360
365
|
- lib/volt/models/persistors/array_store.rb
|
361
366
|
- lib/volt/models/persistors/base.rb
|
362
367
|
- lib/volt/models/persistors/flash.rb
|
368
|
+
- lib/volt/models/persistors/model_identity_map.rb
|
363
369
|
- lib/volt/models/persistors/model_store.rb
|
364
370
|
- lib/volt/models/persistors/params.rb
|
371
|
+
- lib/volt/models/persistors/query/query_listener.rb
|
372
|
+
- lib/volt/models/persistors/query/query_listener_pool.rb
|
365
373
|
- lib/volt/models/persistors/store.rb
|
366
374
|
- lib/volt/models/persistors/store_factory.rb
|
367
375
|
- lib/volt/models/url.rb
|
@@ -375,6 +383,7 @@ files:
|
|
375
383
|
- lib/volt/page/bindings/template_binding.rb
|
376
384
|
- lib/volt/page/channel.rb
|
377
385
|
- lib/volt/page/channel_stub.rb
|
386
|
+
- lib/volt/page/document.rb
|
378
387
|
- lib/volt/page/document_events.rb
|
379
388
|
- lib/volt/page/draw_cycle.rb
|
380
389
|
- lib/volt/page/memory_test.rb
|
@@ -420,6 +429,9 @@ files:
|
|
420
429
|
- lib/volt/server/template_parser.rb
|
421
430
|
- lib/volt/store/mongo.rb
|
422
431
|
- lib/volt/tasks/dispatcher.rb
|
432
|
+
- lib/volt/utils/ejson.rb
|
433
|
+
- lib/volt/utils/generic_counting_pool.rb
|
434
|
+
- lib/volt/utils/generic_pool.rb
|
423
435
|
- lib/volt/volt/environment.rb
|
424
436
|
- spec/app/bootstrap/assets/js/bootstrap.js
|
425
437
|
- spec/app/main/assets/js/test1.js
|
@@ -433,10 +445,12 @@ files:
|
|
433
445
|
- spec/models/persistors/params_spec.rb
|
434
446
|
- spec/models/persistors/store_spec.rb
|
435
447
|
- spec/models/reactive_array_spec.rb
|
448
|
+
- spec/models/reactive_generator_spec.rb
|
436
449
|
- spec/models/reactive_tags_spec.rb
|
437
450
|
- spec/models/reactive_value_spec.rb
|
438
451
|
- spec/models/store_spec.rb
|
439
452
|
- spec/models/string_extensions_spec.rb
|
453
|
+
- spec/page/bindings/content_binding_spec.rb
|
440
454
|
- spec/page/sub_context_spec.rb
|
441
455
|
- spec/router/routes_spec.rb
|
442
456
|
- spec/server/rack/asset_files_spec.rb
|
@@ -444,9 +458,13 @@ files:
|
|
444
458
|
- spec/server/template_parser_spec.rb
|
445
459
|
- spec/spec_helper.rb
|
446
460
|
- spec/store/mongo_spec.rb
|
447
|
-
- spec/tasks/
|
461
|
+
- spec/tasks/live_query_spec.rb
|
462
|
+
- spec/tasks/query_tasks.rb
|
463
|
+
- spec/tasks/query_tracker_spec.rb
|
448
464
|
- spec/templates/targets/binding_document/component_node_spec.rb
|
449
465
|
- spec/templates/template_binding_spec.rb
|
466
|
+
- spec/utils/generic_counting_pool_spec.rb
|
467
|
+
- spec/utils/generic_pool_spec.rb
|
450
468
|
- templates/.gitignore
|
451
469
|
- templates/newgem/Gemfile.tt
|
452
470
|
- templates/newgem/LICENSE.txt.tt
|
@@ -524,10 +542,12 @@ test_files:
|
|
524
542
|
- spec/models/persistors/params_spec.rb
|
525
543
|
- spec/models/persistors/store_spec.rb
|
526
544
|
- spec/models/reactive_array_spec.rb
|
545
|
+
- spec/models/reactive_generator_spec.rb
|
527
546
|
- spec/models/reactive_tags_spec.rb
|
528
547
|
- spec/models/reactive_value_spec.rb
|
529
548
|
- spec/models/store_spec.rb
|
530
549
|
- spec/models/string_extensions_spec.rb
|
550
|
+
- spec/page/bindings/content_binding_spec.rb
|
531
551
|
- spec/page/sub_context_spec.rb
|
532
552
|
- spec/router/routes_spec.rb
|
533
553
|
- spec/server/rack/asset_files_spec.rb
|
@@ -535,7 +555,11 @@ test_files:
|
|
535
555
|
- spec/server/template_parser_spec.rb
|
536
556
|
- spec/spec_helper.rb
|
537
557
|
- spec/store/mongo_spec.rb
|
538
|
-
- spec/tasks/
|
558
|
+
- spec/tasks/live_query_spec.rb
|
559
|
+
- spec/tasks/query_tasks.rb
|
560
|
+
- spec/tasks/query_tracker_spec.rb
|
539
561
|
- spec/templates/targets/binding_document/component_node_spec.rb
|
540
562
|
- spec/templates/template_binding_spec.rb
|
563
|
+
- spec/utils/generic_counting_pool_spec.rb
|
564
|
+
- spec/utils/generic_pool_spec.rb
|
541
565
|
has_rdoc:
|
@@ -1,55 +0,0 @@
|
|
1
|
-
class ChannelTasks
|
2
|
-
@@listeners = {}
|
3
|
-
@@channel_listeners = {}
|
4
|
-
|
5
|
-
# The dispatcher passes its self in
|
6
|
-
def initialize(channel, dispatcher=nil)
|
7
|
-
@channel = channel
|
8
|
-
end
|
9
|
-
|
10
|
-
def add_listener(channel_name, scope={})
|
11
|
-
# Track every channel that is listening
|
12
|
-
@@listeners[channel_name] ||= []
|
13
|
-
@@listeners[channel_name] << @channel
|
14
|
-
|
15
|
-
# Also keep track of which channel names a channel is listening
|
16
|
-
# on so it can be removed if a channel is closed.
|
17
|
-
@@channel_listeners[@channel] ||= {}
|
18
|
-
@@channel_listeners[@channel][channel_name] = true
|
19
|
-
end
|
20
|
-
|
21
|
-
def remove_listener(channel_name, scope={})
|
22
|
-
if @@listeners[channel_name]
|
23
|
-
@@listeners[channel_name].delete(@channel)
|
24
|
-
if @@channel_listeners[@channel]
|
25
|
-
@@channel_listeners[@channel].delete(channel_name)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
# Called when a channel is closed, removes its listeners from
|
31
|
-
# all channels.
|
32
|
-
def close!
|
33
|
-
channel_names = @@channel_listeners.delete(@channel)
|
34
|
-
|
35
|
-
if channel_names
|
36
|
-
channel_names.each_pair do |channel_name,val|
|
37
|
-
remove_listener(channel_name)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def self.send_message_to_channel(channel_name, message, skip_channel=nil)
|
43
|
-
listeners = @@listeners[channel_name]
|
44
|
-
|
45
|
-
if listeners
|
46
|
-
listeners.each do |listener|
|
47
|
-
# We might need to skip a channel if the update came in on this
|
48
|
-
# channel.
|
49
|
-
next if listener == skip_channel
|
50
|
-
|
51
|
-
listener.send_message(*message)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
@@ -1,74 +0,0 @@
|
|
1
|
-
if RUBY_PLATFORM != 'opal'
|
2
|
-
describe "ChannelTasks" do
|
3
|
-
before do
|
4
|
-
load File.join(File.dirname(__FILE__), "../../app/volt/tasks/channel_tasks.rb")
|
5
|
-
end
|
6
|
-
|
7
|
-
after do
|
8
|
-
Object.send(:remove_const, :ChannelTasks)
|
9
|
-
end
|
10
|
-
|
11
|
-
it "should let channels be added and removed" do
|
12
|
-
connection = double('socket connection')
|
13
|
-
|
14
|
-
expect(connection).to receive(:send_message).with('message')
|
15
|
-
|
16
|
-
@channel_task = ChannelTasks.new(connection)
|
17
|
-
@channel_task.add_listener('channel1')
|
18
|
-
|
19
|
-
ChannelTasks.send_message_to_channel('channel1', 'message')
|
20
|
-
end
|
21
|
-
|
22
|
-
it "shouldn't send to channels that aren't listening" do
|
23
|
-
connection1 = double('socket connection1')
|
24
|
-
connection2 = double('socket connection2')
|
25
|
-
|
26
|
-
expect(connection1).to receive(:send_message).with('message for 1')
|
27
|
-
expect(connection1).to_not receive(:send_message).with('message for 2')
|
28
|
-
|
29
|
-
expect(connection2).to_not receive(:send_message).with('message for 1')
|
30
|
-
expect(connection2).to receive(:send_message).with('message for 2')
|
31
|
-
|
32
|
-
@channel_task = ChannelTasks.new(connection1)
|
33
|
-
@channel_task.add_listener('channel1')
|
34
|
-
|
35
|
-
@channel_task = ChannelTasks.new(connection2)
|
36
|
-
@channel_task.add_listener('channel2')
|
37
|
-
|
38
|
-
ChannelTasks.send_message_to_channel('channel1', 'message for 1')
|
39
|
-
ChannelTasks.send_message_to_channel('channel2', 'message for 2')
|
40
|
-
end
|
41
|
-
|
42
|
-
it "should remove channels" do
|
43
|
-
connection = double('socket connection')
|
44
|
-
|
45
|
-
expect(connection).to_not receive(:send_message).with('message for channel1')
|
46
|
-
expect(connection).to receive(:send_message).with('message for channel2')
|
47
|
-
|
48
|
-
@channel_task = ChannelTasks.new(connection)
|
49
|
-
@channel_task.add_listener('channel1')
|
50
|
-
@channel_task.add_listener('channel2')
|
51
|
-
|
52
|
-
ChannelTasks.new(connection).remove_listener('channel1')
|
53
|
-
|
54
|
-
ChannelTasks.send_message_to_channel('channel1', 'message for channel1')
|
55
|
-
ChannelTasks.send_message_to_channel('channel2', 'message for channel2')
|
56
|
-
end
|
57
|
-
|
58
|
-
it "should remove all when the socket is closed" do
|
59
|
-
connection = double('socket connection')
|
60
|
-
|
61
|
-
expect(connection).to_not receive(:send_message).with('message for channel1')
|
62
|
-
expect(connection).to_not receive(:send_message).with('message for channel2')
|
63
|
-
|
64
|
-
@channel_task = ChannelTasks.new(connection)
|
65
|
-
@channel_task.add_listener('channel1')
|
66
|
-
@channel_task.add_listener('channel2')
|
67
|
-
|
68
|
-
ChannelTasks.new(connection).close!
|
69
|
-
|
70
|
-
ChannelTasks.send_message_to_channel('channel1', 'message for channel1')
|
71
|
-
ChannelTasks.send_message_to_channel('channel2', 'message for channel2')
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|