volt 0.8.14 → 0.8.15

Sign up to get free protection for your applications and to get access to all the features.
Files changed (150) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -1
  3. data/Readme.md +8 -2
  4. data/VERSION +1 -1
  5. data/app/volt/controllers/notices_controller.rb +1 -1
  6. data/app/volt/models/user.rb +2 -2
  7. data/app/volt/tasks/live_query/live_query_pool.rb +1 -1
  8. data/app/volt/tasks/query_tasks.rb +1 -1
  9. data/app/volt/tasks/store_tasks.rb +1 -1
  10. data/app/volt/tasks/user_tasks.rb +2 -2
  11. data/lib/volt/boot.rb +2 -2
  12. data/lib/volt/cli/asset_compile.rb +31 -27
  13. data/lib/volt/cli.rb +64 -65
  14. data/lib/volt/config.rb +25 -23
  15. data/lib/volt/console.rb +17 -16
  16. data/lib/volt/controllers/model_controller.rb +82 -80
  17. data/lib/volt/data_stores/data_store.rb +2 -2
  18. data/lib/volt/data_stores/mongo_driver.rb +2 -2
  19. data/lib/volt/extra_core/inflections.rb +2 -2
  20. data/lib/volt/extra_core/inflector/inflections.rb +185 -183
  21. data/lib/volt/extra_core/inflector/methods.rb +50 -48
  22. data/lib/volt/extra_core/string.rb +2 -2
  23. data/lib/volt/models/array_model.rb +93 -92
  24. data/lib/volt/models/cursor.rb +3 -2
  25. data/lib/volt/models/model.rb +248 -251
  26. data/lib/volt/models/model_hash_behaviour.rb +44 -44
  27. data/lib/volt/models/model_helpers.rb +38 -36
  28. data/lib/volt/models/model_state.rb +16 -17
  29. data/lib/volt/models/model_wrapper.rb +25 -24
  30. data/lib/volt/models/persistors/array_store.rb +145 -143
  31. data/lib/volt/models/persistors/base.rb +18 -16
  32. data/lib/volt/models/persistors/flash.rb +24 -22
  33. data/lib/volt/models/persistors/local_store.rb +46 -44
  34. data/lib/volt/models/persistors/model_identity_map.rb +10 -8
  35. data/lib/volt/models/persistors/model_store.rb +76 -76
  36. data/lib/volt/models/persistors/params.rb +19 -17
  37. data/lib/volt/models/persistors/query/query_listener.rb +65 -63
  38. data/lib/volt/models/persistors/query/query_listener_pool.rb +12 -10
  39. data/lib/volt/models/persistors/store.rb +28 -28
  40. data/lib/volt/models/persistors/store_factory.rb +12 -10
  41. data/lib/volt/models/persistors/store_state.rb +33 -31
  42. data/lib/volt/models/url.rb +96 -104
  43. data/lib/volt/models/validations.rb +56 -54
  44. data/lib/volt/models/validators/length_validator.rb +24 -22
  45. data/lib/volt/models/validators/presence_validator.rb +14 -12
  46. data/lib/volt/page/bindings/attribute_binding.rb +106 -106
  47. data/lib/volt/page/bindings/base_binding.rb +23 -21
  48. data/lib/volt/page/bindings/component_binding.rb +3 -1
  49. data/lib/volt/page/bindings/content_binding.rb +34 -34
  50. data/lib/volt/page/bindings/each_binding.rb +113 -113
  51. data/lib/volt/page/bindings/event_binding.rb +38 -34
  52. data/lib/volt/page/bindings/if_binding.rb +56 -54
  53. data/lib/volt/page/bindings/template_binding/grouped_controllers.rb +24 -22
  54. data/lib/volt/page/bindings/template_binding.rb +182 -185
  55. data/lib/volt/page/channel.rb +79 -77
  56. data/lib/volt/page/channel_stub.rb +29 -27
  57. data/lib/volt/page/document.rb +6 -5
  58. data/lib/volt/page/document_events.rb +54 -52
  59. data/lib/volt/page/page.rb +139 -138
  60. data/lib/volt/page/string_template_renderer.rb +36 -36
  61. data/lib/volt/page/sub_context.rb +26 -25
  62. data/lib/volt/page/targets/attribute_section.rb +27 -25
  63. data/lib/volt/page/targets/attribute_target.rb +7 -6
  64. data/lib/volt/page/targets/base_section.rb +27 -26
  65. data/lib/volt/page/targets/binding_document/base_node.rb +3 -1
  66. data/lib/volt/page/targets/binding_document/component_node.rb +85 -82
  67. data/lib/volt/page/targets/binding_document/html_node.rb +11 -9
  68. data/lib/volt/page/targets/dom_section.rb +78 -77
  69. data/lib/volt/page/targets/dom_target.rb +8 -6
  70. data/lib/volt/page/targets/dom_template.rb +90 -88
  71. data/lib/volt/page/targets/helpers/comment_searchers.rb +51 -49
  72. data/lib/volt/page/tasks.rb +59 -57
  73. data/lib/volt/page/template_renderer.rb +17 -14
  74. data/lib/volt/page/url_tracker.rb +26 -24
  75. data/lib/volt/reactive/computation.rb +87 -88
  76. data/lib/volt/reactive/dependency.rb +30 -28
  77. data/lib/volt/reactive/eventable.rb +64 -62
  78. data/lib/volt/reactive/hash_dependency.rb +25 -23
  79. data/lib/volt/reactive/reactive_accessors.rb +34 -32
  80. data/lib/volt/reactive/reactive_array.rb +162 -162
  81. data/lib/volt/reactive/reactive_hash.rb +37 -35
  82. data/lib/volt/router/routes.rb +99 -101
  83. data/lib/volt/server/component_handler.rb +20 -21
  84. data/lib/volt/server/component_templates.rb +72 -70
  85. data/lib/volt/server/html_parser/attribute_scope.rb +109 -99
  86. data/lib/volt/server/html_parser/each_scope.rb +17 -16
  87. data/lib/volt/server/html_parser/if_view_scope.rb +51 -49
  88. data/lib/volt/server/html_parser/sandlebars_parser.rb +184 -177
  89. data/lib/volt/server/html_parser/textarea_scope.rb +24 -22
  90. data/lib/volt/server/html_parser/view_handler.rb +66 -65
  91. data/lib/volt/server/html_parser/view_parser.rb +23 -21
  92. data/lib/volt/server/html_parser/view_scope.rb +142 -141
  93. data/lib/volt/server/rack/asset_files.rb +81 -79
  94. data/lib/volt/server/rack/component_code.rb +17 -15
  95. data/lib/volt/server/rack/component_html_renderer.rb +14 -12
  96. data/lib/volt/server/rack/component_paths.rb +72 -71
  97. data/lib/volt/server/rack/index_files.rb +36 -39
  98. data/lib/volt/server/rack/opal_files.rb +43 -41
  99. data/lib/volt/server/rack/source_map_server.rb +23 -21
  100. data/lib/volt/server/socket_connection_handler.rb +46 -45
  101. data/lib/volt/server/socket_connection_handler_stub.rb +21 -19
  102. data/lib/volt/server.rb +60 -58
  103. data/lib/volt/spec/setup.rb +3 -3
  104. data/lib/volt/tasks/dispatcher.rb +24 -23
  105. data/lib/volt/tasks/task_handler.rb +35 -33
  106. data/lib/volt/utils/ejson.rb +8 -6
  107. data/lib/volt/utils/generic_counting_pool.rb +33 -31
  108. data/lib/volt/utils/generic_pool.rb +73 -70
  109. data/lib/volt/utils/local_storage.rb +42 -38
  110. data/lib/volt/volt/environment.rb +1 -1
  111. data/lib/volt.rb +44 -42
  112. data/spec/apps/kitchen_sink/app/main/assets/css/todos.css +28 -0
  113. data/spec/apps/kitchen_sink/app/main/config/routes.rb +1 -0
  114. data/spec/apps/kitchen_sink/app/main/controllers/main_controller.rb +2 -2
  115. data/spec/apps/kitchen_sink/app/main/controllers/todos_controller.rb +17 -0
  116. data/spec/apps/kitchen_sink/app/main/views/main/main.html +1 -0
  117. data/spec/apps/kitchen_sink/app/main/views/todos/index.html +24 -0
  118. data/spec/apps/kitchen_sink/config.ru +1 -1
  119. data/spec/controllers/reactive_accessors_spec.rb +5 -5
  120. data/spec/extra_core/inflector_spec.rb +2 -2
  121. data/spec/integration/list_spec.rb +68 -0
  122. data/spec/models/model_spec.rb +57 -57
  123. data/spec/models/persistors/params_spec.rb +6 -6
  124. data/spec/models/persistors/store_spec.rb +7 -7
  125. data/spec/models/validations_spec.rb +3 -3
  126. data/spec/page/bindings/content_binding_spec.rb +7 -7
  127. data/spec/page/bindings/template_binding_spec.rb +4 -5
  128. data/spec/page/sub_context_spec.rb +2 -2
  129. data/spec/reactive/computation_spec.rb +10 -10
  130. data/spec/reactive/dependency_spec.rb +2 -2
  131. data/spec/reactive/eventable_spec.rb +4 -4
  132. data/spec/reactive/reactive_array_spec.rb +13 -13
  133. data/spec/router/routes_spec.rb +5 -5
  134. data/spec/server/html_parser/sandlebars_parser_spec.rb +9 -9
  135. data/spec/server/html_parser/view_parser_spec.rb +27 -27
  136. data/spec/server/rack/asset_files_spec.rb +5 -5
  137. data/spec/server/rack/component_paths_spec.rb +2 -2
  138. data/spec/tasks/live_query_spec.rb +2 -2
  139. data/spec/tasks/query_tasks.rb +1 -1
  140. data/spec/tasks/query_tracker_spec.rb +1 -1
  141. data/spec/templates/targets/binding_document/component_node_spec.rb +2 -2
  142. data/spec/utils/generic_counting_pool_spec.rb +2 -2
  143. data/spec/utils/generic_pool_spec.rb +2 -2
  144. data/templates/component/controllers/main_controller.rb +1 -1
  145. data/templates/model/model.rb.tt +2 -2
  146. data/templates/newgem/app/newgem/controllers/main_controller.rb.tt +2 -2
  147. data/templates/project/app/main/controllers/main_controller.rb +1 -1
  148. data/templates/project/config.ru +1 -1
  149. metadata +10 -3
  150. data/app/volt/assets/js/vertxbus.js +0 -216
@@ -3,127 +3,128 @@ require 'volt/models/model_wrapper'
3
3
  require 'volt/models/model_helpers'
4
4
  require 'volt/models/model_state'
5
5
 
6
- class ArrayModel < ReactiveArray
7
- include ModelWrapper
8
- include ModelHelpers
9
- include ModelState
10
-
11
- attr_reader :parent, :path, :persistor, :options, :array
12
-
13
- # For many methods, we want to call load data as soon as the model is interacted
14
- # with, so we proxy the method, then call super.
15
- def self.proxy_with_load_data(*method_names)
16
- method_names.each do |method_name|
17
- define_method(method_name) do |*args|
18
- load_data
19
- super(*args)
6
+ module Volt
7
+ class ArrayModel < ReactiveArray
8
+ include ModelWrapper
9
+ include ModelHelpers
10
+ include ModelState
11
+
12
+ attr_reader :parent, :path, :persistor, :options, :array
13
+
14
+ # For many methods, we want to call load data as soon as the model is interacted
15
+ # with, so we proxy the method, then call super.
16
+ def self.proxy_with_load_data(*method_names)
17
+ method_names.each do |method_name|
18
+ define_method(method_name) do |*args|
19
+ load_data
20
+ super(*args)
21
+ end
20
22
  end
21
23
  end
22
- end
23
-
24
- proxy_with_load_data :[], :size, :first, :last
25
24
 
26
- def initialize(array=[], options={})
27
- @options = options
28
- @parent = options[:parent]
29
- @path = options[:path] || []
30
- @persistor = setup_persistor(options[:persistor])
25
+ proxy_with_load_data :[], :size, :first, :last
31
26
 
32
- array = wrap_values(array)
27
+ def initialize(array=[], options={})
28
+ @options = options
29
+ @parent = options[:parent]
30
+ @path = options[:path] || []
31
+ @persistor = setup_persistor(options[:persistor])
33
32
 
34
- super(array)
33
+ array = wrap_values(array)
35
34
 
36
- @persistor.loaded if @persistor
37
- end
35
+ super(array)
38
36
 
39
- def find(*args, &block)
40
- if @persistor
41
- return @persistor.find(*args, &block)
42
- else
43
- raise "this model's persistance layer does not support find, try using store"
37
+ @persistor.loaded if @persistor
44
38
  end
45
- end
46
39
 
47
- def then(*args, &block)
48
- if @persistor
49
- return @persistor.then(*args, &block)
50
- else
51
- raise "this model's persistance layer does not support then, try using store"
40
+ def find(*args, &block)
41
+ if @persistor
42
+ return @persistor.find(*args, &block)
43
+ else
44
+ raise "this model's persistance layer does not support find, try using store"
45
+ end
52
46
  end
53
- end
54
47
 
55
- def attributes
56
- self
57
- end
48
+ def then(*args, &block)
49
+ if @persistor
50
+ @persistor.then(*args, &block)
51
+ else
52
+ raise "this model's persistance layer does not support then, try using store"
53
+ end
54
+ end
58
55
 
59
- # Make sure it gets wrapped
60
- def <<(model)
61
- if model.is_a?(Model)
62
- # Set the new path
63
- model.options = @options.merge(path: @options[:path] + [:[]])
64
- else
65
- model = wrap_values([model]).first
56
+ def attributes
57
+ self
66
58
  end
67
59
 
68
- super(model)
60
+ # Make sure it gets wrapped
61
+ def <<(model)
62
+ if model.is_a?(Model)
63
+ # Set the new path
64
+ model.options = @options.merge(path: @options[:path] + [:[]])
65
+ else
66
+ model = wrap_values([model]).first
67
+ end
69
68
 
70
- @persistor.added(model, @array.size-1) if @persistor
69
+ super(model)
71
70
 
72
- return model
73
- end
74
- alias_method :append, :<<
71
+ @persistor.added(model, @array.size-1) if @persistor
75
72
 
76
- # Make sure it gets wrapped
77
- def inject(*args)
78
- args = wrap_values(args)
79
- super(*args)
80
- end
73
+ model
74
+ end
81
75
 
82
- # Make sure it gets wrapped
83
- def +(*args)
84
- args = wrap_values(args)
85
- super(*args)
86
- end
76
+ alias_method :append, :<<
87
77
 
88
- def new_model(*args)
89
- class_at_path(options[:path]).new(*args)
90
- end
78
+ # Make sure it gets wrapped
79
+ def inject(*args)
80
+ args = wrap_values(args)
81
+ super(*args)
82
+ end
91
83
 
92
- def new_array_model(*args)
93
- ArrayModel.new(*args)
94
- end
84
+ # Make sure it gets wrapped
85
+ def +(*args)
86
+ args = wrap_values(args)
87
+ super(*args)
88
+ end
95
89
 
96
- # Convert the model to an array all of the way down
97
- def to_a
98
- array = []
99
- attributes.each do |value|
100
- array << deep_unwrap(value)
90
+ def new_model(*args)
91
+ class_at_path(options[:path]).new(*args)
101
92
  end
102
93
 
103
- return array
104
- end
94
+ def new_array_model(*args)
95
+ ArrayModel.new(*args)
96
+ end
105
97
 
106
- def inspect
107
- if @persistor && @persistor.is_a?(Persistors::ArrayStore) && state == :not_loaded
108
- # Show a special message letting users know it is not loaded yet.
109
- return "#<#{self.class.to_s}:not loaded, access with [] or size to load>"
98
+ # Convert the model to an array all of the way down
99
+ def to_a
100
+ array = []
101
+ attributes.each do |value|
102
+ array << deep_unwrap(value)
103
+ end
104
+ array
110
105
  end
111
106
 
112
- # Otherwise inspect normally
113
- return super
114
- end
107
+ def inspect
108
+ if @persistor && @persistor.is_a?(Persistors::ArrayStore) && state == :not_loaded
109
+ # Show a special message letting users know it is not loaded yet.
110
+ "#<#{self.class.to_s}:not loaded, access with [] or size to load>"
111
+ else
112
+ # Otherwise inspect normally
113
+ super
114
+ end
115
+ end
115
116
 
116
- def buffer
117
- model_path = options[:path] + [:[]]
118
- model_klass = class_at_path(model_path)
117
+ def buffer
118
+ model_path = options[:path] + [:[]]
119
+ model_klass = class_at_path(model_path)
119
120
 
120
- new_options = options.merge(path: model_path, save_to: self).reject {|k,_| k.to_sym == :persistor }
121
- model = model_klass.new({}, new_options)
121
+ new_options = options.merge(path: model_path, save_to: self).reject { |k, _| k.to_sym == :persistor }
122
+ model = model_klass.new({}, new_options)
122
123
 
123
- return model
124
- end
124
+ model
125
+ end
125
126
 
126
- private
127
+ private
127
128
  # Takes the persistor if there is one and
128
129
  def setup_persistor(persistor)
129
130
  if persistor
@@ -137,5 +138,5 @@ class ArrayModel < ReactiveArray
137
138
  @persistor.load_data
138
139
  end
139
140
  end
140
-
141
+ end
141
142
  end
@@ -1,6 +1,7 @@
1
1
  require 'volt/models/array_model'
2
2
 
3
- class Cursor < ArrayModel
4
-
3
+ module Volt
4
+ class Cursor < ArrayModel
5
5
 
6
+ end
6
7
  end