volt 0.6.5 → 0.7.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 +4 -4
- data/Readme.md +47 -40
- data/VERSION +1 -1
- data/app/volt/controllers/notices_controller.rb +3 -3
- data/app/volt/tasks/live_query/data_store.rb +2 -2
- data/app/volt/tasks/live_query/live_query.rb +20 -20
- data/app/volt/tasks/live_query/live_query_pool.rb +6 -6
- data/app/volt/tasks/live_query/query_tracker.rb +15 -15
- data/app/volt/tasks/query_tasks.rb +13 -13
- data/app/volt/tasks/store_tasks.rb +7 -7
- data/app/volt/views/notices/index.html +17 -18
- data/lib/volt/assets/test.rb +2 -2
- data/lib/volt/benchmark/benchmark.rb +25 -23
- data/lib/volt/cli/asset_compile.rb +11 -0
- data/lib/volt/cli/new_gem.rb +16 -16
- data/lib/volt/cli.rb +14 -12
- data/lib/volt/console.rb +5 -6
- data/lib/volt/controllers/model_controller.rb +18 -18
- data/lib/volt/extra_core/array.rb +4 -4
- data/lib/volt/extra_core/hash.rb +3 -3
- data/lib/volt/extra_core/object.rb +6 -6
- data/lib/volt/extra_core/string.rb +6 -6
- data/lib/volt/extra_core/symbol.rb +5 -5
- data/lib/volt/extra_core/time.rb +4 -4
- data/lib/volt/extra_core/true_false.rb +6 -6
- data/lib/volt/extra_core/try.rb +9 -9
- data/lib/volt/models/array_model.rb +26 -26
- data/lib/volt/models/model.rb +35 -35
- data/lib/volt/models/model_hash_behaviour.rb +15 -15
- data/lib/volt/models/model_helpers.rb +8 -8
- data/lib/volt/models/model_wrapper.rb +6 -6
- data/lib/volt/models/persistors/array_store.rb +36 -36
- data/lib/volt/models/persistors/base.rb +6 -6
- data/lib/volt/models/persistors/flash.rb +5 -5
- data/lib/volt/models/persistors/model_identity_map.rb +2 -2
- data/lib/volt/models/persistors/model_store.rb +22 -22
- data/lib/volt/models/persistors/params.rb +3 -3
- data/lib/volt/models/persistors/query/query_listener.rb +14 -14
- data/lib/volt/models/persistors/query/query_listener_pool.rb +2 -2
- data/lib/volt/models/persistors/store.rb +8 -8
- data/lib/volt/models/persistors/store_factory.rb +2 -2
- data/lib/volt/models/url.rb +37 -37
- data/lib/volt/page/bindings/attribute_binding.rb +14 -14
- data/lib/volt/page/bindings/base_binding.rb +9 -9
- data/lib/volt/page/bindings/component_binding.rb +7 -7
- data/lib/volt/page/bindings/content_binding.rb +3 -3
- data/lib/volt/page/bindings/each_binding.rb +13 -13
- data/lib/volt/page/bindings/event_binding.rb +4 -4
- data/lib/volt/page/bindings/if_binding.rb +12 -12
- data/lib/volt/page/bindings/template_binding.rb +30 -30
- data/lib/volt/page/channel.rb +19 -19
- data/lib/volt/page/channel_stub.rb +6 -6
- data/lib/volt/page/document.rb +2 -2
- data/lib/volt/page/document_events.rb +4 -4
- data/lib/volt/page/draw_cycle.rb +3 -3
- data/lib/volt/page/memory_test.rb +6 -6
- data/lib/volt/page/page.rb +19 -19
- data/lib/volt/page/reactive_template.rb +9 -9
- data/lib/volt/page/sub_context.rb +5 -5
- data/lib/volt/page/targets/attribute_section.rb +9 -9
- data/lib/volt/page/targets/attribute_target.rb +3 -3
- data/lib/volt/page/targets/base_section.rb +2 -2
- data/lib/volt/page/targets/binding_document/component_node.rb +23 -23
- data/lib/volt/page/targets/binding_document/html_node.rb +2 -2
- data/lib/volt/page/targets/dom_section.rb +40 -38
- data/lib/volt/page/targets/dom_target.rb +2 -2
- data/lib/volt/page/tasks.rb +12 -12
- data/lib/volt/page/template_renderer.rb +4 -4
- data/lib/volt/page/url_tracker.rb +6 -6
- data/lib/volt/reactive/array_extensions.rb +2 -2
- data/lib/volt/reactive/destructive_methods.rb +5 -5
- data/lib/volt/reactive/event_chain.rb +25 -25
- data/lib/volt/reactive/events.rb +33 -33
- data/lib/volt/reactive/object_tracker.rb +21 -21
- data/lib/volt/reactive/object_tracking.rb +2 -2
- data/lib/volt/reactive/reactive_array.rb +57 -57
- data/lib/volt/reactive/reactive_tags.rb +16 -16
- data/lib/volt/reactive/reactive_value.rb +72 -72
- data/lib/volt/reactive/string_extensions.rb +3 -3
- data/lib/volt/router/routes.rb +22 -23
- data/lib/volt/server/component_handler.rb +5 -5
- data/lib/volt/server/component_templates.rb +14 -11
- data/lib/volt/server/html_parser/attribute_scope.rb +116 -0
- data/lib/volt/server/html_parser/each_scope.rb +18 -0
- data/lib/volt/server/html_parser/if_view_scope.rb +71 -0
- data/lib/volt/server/html_parser/sandlebars_parser.rb +219 -0
- data/lib/volt/server/html_parser/textarea_scope.rb +31 -0
- data/lib/volt/server/html_parser/view_handler.rb +82 -0
- data/lib/volt/server/html_parser/view_parser.rb +23 -0
- data/lib/volt/server/html_parser/view_scope.rb +145 -0
- data/lib/volt/server/rack/asset_files.rb +17 -17
- data/lib/volt/server/rack/component_paths.rb +18 -18
- data/lib/volt/server/rack/index_files.rb +8 -8
- data/lib/volt/server/rack/opal_files.rb +11 -11
- data/lib/volt/server/socket_connection_handler.rb +13 -13
- data/lib/volt/server/socket_connection_handler_stub.rb +2 -2
- data/lib/volt/server.rb +18 -18
- data/lib/volt/tasks/dispatcher.rb +5 -5
- data/lib/volt/utils/ejson.rb +2 -2
- data/lib/volt/utils/generic_counting_pool.rb +8 -8
- data/lib/volt/utils/generic_pool.rb +16 -16
- data/lib/volt/volt/environment.rb +4 -4
- data/lib/volt.rb +6 -6
- data/spec/integration/test_integration_spec.rb +2 -2
- data/spec/models/event_chain_spec.rb +38 -38
- data/spec/models/model_spec.rb +128 -128
- data/spec/models/old_model_spec.rb +17 -17
- data/spec/models/persistors/params_spec.rb +3 -3
- data/spec/models/persistors/store_spec.rb +7 -7
- data/spec/models/reactive_array_spec.rb +82 -82
- data/spec/models/reactive_generator_spec.rb +11 -11
- data/spec/models/reactive_tags_spec.rb +6 -6
- data/spec/models/reactive_value_spec.rb +70 -70
- data/spec/models/store_spec.rb +4 -4
- data/spec/models/string_extensions_spec.rb +13 -13
- data/spec/page/bindings/content_binding_spec.rb +6 -6
- data/spec/page/sub_context_spec.rb +1 -1
- data/spec/router/routes_spec.rb +3 -3
- data/spec/server/html_parser/sample_page.html +595 -0
- data/spec/server/html_parser/sandlebars_parser_spec.rb +192 -0
- data/spec/server/html_parser/view_parser_spec.rb +286 -0
- data/spec/server/rack/asset_files_spec.rb +6 -6
- data/spec/server/rack/component_paths_spec.rb +5 -5
- data/spec/spec_helper.rb +4 -5
- data/spec/store/mongo_spec.rb +3 -3
- data/spec/tasks/live_query_spec.rb +6 -6
- data/spec/tasks/query_tasks.rb +4 -4
- data/spec/tasks/query_tracker_spec.rb +20 -20
- data/spec/templates/targets/binding_document/component_node_spec.rb +4 -4
- data/spec/templates/template_binding_spec.rb +28 -28
- data/spec/utils/generic_counting_pool_spec.rb +5 -5
- data/spec/utils/generic_pool_spec.rb +14 -14
- data/templates/newgem/app/newgem/views/index/index.html +1 -2
- data/templates/project/app/home/config/dependencies.rb +1 -1
- data/templates/project/app/home/controllers/index_controller.rb +1 -1
- data/templates/project/app/home/views/index/about.html +4 -6
- data/templates/project/app/home/views/index/home.html +4 -5
- data/templates/project/app/home/views/index/index.html +8 -9
- data/templates/project/spec/spec_helper.rb +1 -1
- metadata +17 -8
- data/lib/volt/server/binding_setup.rb +0 -2
- data/lib/volt/server/if_binding_setup.rb +0 -31
- data/lib/volt/server/scope.rb +0 -43
- data/lib/volt/server/template_parser.rb +0 -453
- data/spec/server/template_parser_spec.rb +0 -50
|
@@ -3,11 +3,11 @@ class Volt
|
|
|
3
3
|
def initialize
|
|
4
4
|
@env = ENV['VOLT_ENV'] || 'development'
|
|
5
5
|
end
|
|
6
|
-
|
|
6
|
+
|
|
7
7
|
def ==(val)
|
|
8
8
|
@env == val
|
|
9
9
|
end
|
|
10
|
-
|
|
10
|
+
|
|
11
11
|
def production?
|
|
12
12
|
self.==('production')
|
|
13
13
|
end
|
|
@@ -19,9 +19,9 @@ class Volt
|
|
|
19
19
|
def development?
|
|
20
20
|
self.==('development')
|
|
21
21
|
end
|
|
22
|
-
|
|
22
|
+
|
|
23
23
|
def inspect
|
|
24
24
|
@env.inspect
|
|
25
25
|
end
|
|
26
26
|
end
|
|
27
|
-
end
|
|
27
|
+
end
|
data/lib/volt.rb
CHANGED
|
@@ -6,24 +6,24 @@ class Volt
|
|
|
6
6
|
def self.root
|
|
7
7
|
@root ||= File.expand_path(Dir.pwd)
|
|
8
8
|
end
|
|
9
|
-
|
|
9
|
+
|
|
10
10
|
def self.root=(val)
|
|
11
11
|
@root = val
|
|
12
12
|
end
|
|
13
|
-
|
|
13
|
+
|
|
14
14
|
def self.server?
|
|
15
15
|
!!ENV['SERVER']
|
|
16
16
|
end
|
|
17
|
-
|
|
17
|
+
|
|
18
18
|
def self.client?
|
|
19
19
|
!ENV['SERVER']
|
|
20
20
|
end
|
|
21
|
-
|
|
21
|
+
|
|
22
22
|
def self.source_maps?
|
|
23
23
|
!!ENV['MAPS']
|
|
24
24
|
end
|
|
25
|
-
|
|
25
|
+
|
|
26
26
|
def self.env
|
|
27
27
|
@env ||= Volt::Environment.new
|
|
28
28
|
end
|
|
29
|
-
end
|
|
29
|
+
end
|
|
@@ -3,129 +3,129 @@ require 'volt/models'
|
|
|
3
3
|
describe EventChain do
|
|
4
4
|
before do
|
|
5
5
|
@a = ReactiveValue.new(1)
|
|
6
|
-
@b = ReactiveValue.new(2)
|
|
6
|
+
@b = ReactiveValue.new(2)
|
|
7
7
|
end
|
|
8
|
-
|
|
8
|
+
|
|
9
9
|
it "should chain events when we use add_object" do
|
|
10
|
-
|
|
10
|
+
|
|
11
11
|
count = 0
|
|
12
12
|
@b.on('changed') { count += 1 }
|
|
13
13
|
@b.reactive_manager.event_chain.add_object(@a)
|
|
14
14
|
expect(count).to eq(0)
|
|
15
|
-
|
|
15
|
+
|
|
16
16
|
@a.trigger!('changed')
|
|
17
17
|
expect(count).to eq(1)
|
|
18
18
|
end
|
|
19
|
-
|
|
19
|
+
|
|
20
20
|
it "should chain events after add_object is called" do
|
|
21
21
|
@b.reactive_manager.event_chain.add_object(@a)
|
|
22
|
-
|
|
22
|
+
|
|
23
23
|
add_count = 0
|
|
24
24
|
@b.on('added') { add_count += 1 }
|
|
25
25
|
expect(add_count).to eq(0)
|
|
26
26
|
@a.trigger!('added')
|
|
27
|
-
|
|
28
|
-
expect(add_count).to eq(1)
|
|
27
|
+
|
|
28
|
+
expect(add_count).to eq(1)
|
|
29
29
|
end
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
|
|
31
|
+
|
|
32
32
|
it "should remove events" do
|
|
33
33
|
@b.reactive_manager.event_chain.add_object(@a)
|
|
34
|
-
|
|
34
|
+
|
|
35
35
|
add_count = 0
|
|
36
36
|
listener = @b.on('added') { add_count += 1 }
|
|
37
37
|
expect(add_count).to eq(0)
|
|
38
38
|
@a.trigger!('added')
|
|
39
|
-
|
|
39
|
+
|
|
40
40
|
expect(add_count).to eq(1)
|
|
41
|
-
|
|
41
|
+
|
|
42
42
|
# Make sure the event is registered
|
|
43
43
|
# TODO: currently fails
|
|
44
44
|
# expect(@a.reactive_manager.listeners.size).to eq(1)
|
|
45
45
|
expect(@b.reactive_manager.event_chain.instance_variable_get('@event_chain').values[0].keys.include?(:added)).to eq(true)
|
|
46
|
-
|
|
46
|
+
|
|
47
47
|
listener.remove
|
|
48
|
-
|
|
48
|
+
|
|
49
49
|
# Make sure its removed
|
|
50
50
|
# TODO: also fails
|
|
51
51
|
# expect(@a.reactive_manager.listeners.size).to eq(0)
|
|
52
52
|
expect(@b.reactive_manager.event_chain.instance_variable_get('@event_chain').values[0].keys.include?(:added)).to eq(false)
|
|
53
|
-
|
|
53
|
+
|
|
54
54
|
@a.trigger!('added')
|
|
55
55
|
expect(add_count).to eq(1)
|
|
56
56
|
end
|
|
57
|
-
|
|
57
|
+
|
|
58
58
|
it "should unchain directly" do
|
|
59
59
|
count = 0
|
|
60
60
|
a = ReactiveValue.new(Model.new)
|
|
61
61
|
b = a._name
|
|
62
62
|
listener = b.on('changed') { count += 1 }
|
|
63
|
-
|
|
63
|
+
|
|
64
64
|
expect(b.reactive_manager.listeners[:changed].size).to eq(1)
|
|
65
65
|
# TODO: ideally this would only bind 1 to a
|
|
66
66
|
expect(a.reactive_manager.listeners[:changed].size).to eq(1)
|
|
67
|
-
|
|
67
|
+
|
|
68
68
|
listener.remove
|
|
69
|
-
|
|
69
|
+
|
|
70
70
|
expect(b.reactive_manager.listeners[:changed]).to eq(nil)
|
|
71
71
|
expect(a.reactive_manager.listeners[:changed]).to eq(nil)
|
|
72
72
|
end
|
|
73
|
-
|
|
73
|
+
|
|
74
74
|
it "should unchain" do
|
|
75
75
|
count = 0
|
|
76
76
|
@b.on('changed') { count += 1 }
|
|
77
77
|
b_object_listener = @b.reactive_manager.event_chain.add_object(@a)
|
|
78
78
|
expect(count).to eq(0)
|
|
79
|
-
|
|
79
|
+
|
|
80
80
|
@a.trigger!('changed')
|
|
81
81
|
expect(count).to eq(1)
|
|
82
|
-
|
|
82
|
+
|
|
83
83
|
b_object_listener.remove
|
|
84
|
-
|
|
84
|
+
|
|
85
85
|
@a.trigger!('changed')
|
|
86
86
|
expect(count).to eq(1)
|
|
87
87
|
end
|
|
88
|
-
|
|
88
|
+
|
|
89
89
|
it "should unchain up the chain" do
|
|
90
90
|
count = 0
|
|
91
91
|
a = ReactiveValue.new(Model.new)
|
|
92
|
-
|
|
92
|
+
|
|
93
93
|
b = a._list
|
|
94
94
|
expect(a.reactive_manager.listeners.size).to eq(0)
|
|
95
95
|
listener = b.on('changed') { count += 1 }
|
|
96
|
-
|
|
96
|
+
|
|
97
97
|
expect(a.reactive_manager.listeners.size).to eq(1)
|
|
98
|
-
|
|
98
|
+
|
|
99
99
|
listener.remove
|
|
100
|
-
|
|
100
|
+
|
|
101
101
|
expect(a.reactive_manager.listeners.size).to eq(0)
|
|
102
102
|
end
|
|
103
|
-
|
|
103
|
+
|
|
104
104
|
describe "double add/removes" do
|
|
105
105
|
it "should unchain" do
|
|
106
106
|
c = ReactiveValue.new(3)
|
|
107
107
|
count = 0
|
|
108
108
|
@b.on('changed') { count += 1 }
|
|
109
109
|
c.on('changed') { count += 1 }
|
|
110
|
-
|
|
111
|
-
|
|
110
|
+
|
|
111
|
+
|
|
112
112
|
# Chain b to a
|
|
113
113
|
b_object_listener = @b.reactive_manager.event_chain.add_object(@a)
|
|
114
114
|
c_object_listener = c.reactive_manager.event_chain.add_object(@a)
|
|
115
115
|
expect(count).to eq(0)
|
|
116
|
-
|
|
116
|
+
|
|
117
117
|
@a.trigger!('changed')
|
|
118
118
|
expect(count).to eq(2)
|
|
119
|
-
|
|
119
|
+
|
|
120
120
|
b_object_listener.remove
|
|
121
|
-
|
|
121
|
+
|
|
122
122
|
@a.trigger!('changed')
|
|
123
123
|
expect(count).to eq(3)
|
|
124
|
-
|
|
124
|
+
|
|
125
125
|
c_object_listener.remove
|
|
126
|
-
|
|
126
|
+
|
|
127
127
|
@a.trigger!('changed')
|
|
128
128
|
expect(count).to eq(3)
|
|
129
129
|
end
|
|
130
130
|
end
|
|
131
|
-
end
|
|
131
|
+
end
|