volt 0.9.1.pre4 → 0.9.1.pre5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/CONTRIBUTING.md +1 -1
- data/README.md +1 -0
- data/app/volt/tasks/query_tasks.rb +4 -3
- data/app/volt/tasks/store_tasks.rb +1 -1
- data/lib/volt/boot.rb +8 -7
- data/lib/volt/cli/asset_compile.rb +1 -1
- data/lib/volt/cli/console.rb +14 -3
- data/lib/volt/cli/new_gem.rb +3 -3
- data/lib/volt/cli.rb +3 -3
- data/lib/volt/config.rb +7 -1
- data/lib/volt/data_stores/base.rb +7 -0
- data/lib/volt/data_stores/data_store.rb +10 -3
- data/lib/volt/data_stores/mongo_driver.rb +58 -7
- data/lib/volt/models/associations.rb +2 -2
- data/lib/volt/models/persistors/array_store.rb +24 -6
- data/lib/volt/models/persistors/base.rb +4 -0
- data/lib/volt/models/persistors/model_store.rb +4 -15
- data/lib/volt/page/bindings/attribute_binding.rb +17 -15
- data/lib/volt/page/bindings/each_binding.rb +14 -17
- data/lib/volt/page/bindings/view_binding/controller_handler.rb +24 -0
- data/lib/volt/page/bindings/view_binding.rb +10 -30
- data/lib/volt/page/document_events.rb +7 -4
- data/lib/volt/page/page.rb +19 -13
- data/lib/volt/page/path_string_renderer.rb +41 -0
- data/lib/volt/page/targets/dom_section.rb +5 -2
- data/lib/volt/reactive/computation.rb +3 -1
- data/lib/volt/reactive/reactive_accessors.rb +8 -7
- data/lib/volt/reactive/reactive_array.rb +2 -0
- data/lib/volt/server/component_handler.rb +3 -3
- data/lib/volt/server/component_templates.rb +32 -6
- data/lib/volt/server/forking_server.rb +4 -2
- data/lib/volt/server/rack/asset_files.rb +5 -1
- data/lib/volt/server/rack/component_paths.rb +6 -4
- data/lib/volt/server/rack/opal_files.rb +16 -11
- data/lib/volt/server/rack/quiet_common_logger.rb +1 -1
- data/lib/volt/server.rb +1 -1
- data/lib/volt/spec/setup.rb +1 -1
- data/lib/volt/version.rb +5 -0
- data/lib/volt/volt/app.rb +12 -2
- data/spec/apps/kitchen_sink/app/main/views/mailers/welcome.email +12 -0
- data/spec/integration/http_endpoints_spec.rb +1 -3
- data/spec/integration/user_spec.rb +0 -10
- data/spec/models/associations_spec.rb +0 -3
- data/spec/models/model_spec.rb +13 -0
- data/spec/models/persistors/flash_spec.rb +45 -0
- data/spec/models/validators/phone_number_validator_spec.rb +2 -2
- data/spec/page/bindings/template_binding/view_lookup_for_path_spec.rb +0 -5
- data/spec/page/path_string_renderer_spec.rb +23 -0
- data/spec/page/sub_context_spec.rb +1 -0
- data/spec/router/routes_spec.rb +24 -5
- data/spec/server/html_parser/view_handler_spec.rb +20 -0
- data/spec/server/rack/quite_common_logger_spec.rb +3 -3
- data/spec/spec_helper.rb +0 -4
- data/spec/tasks/query_tracker_spec.rb +30 -0
- data/templates/newgem/lib/newgem/version.rb.tt +7 -0
- data/templates/newgem/newgem.gemspec.tt +2 -4
- data/templates/project/Gemfile.tt +5 -2
- data/templates/project/config/app.rb.tt +49 -1
- data/volt.gemspec +12 -10
- metadata +24 -28
- data/VERSION +0 -1
- data/app/volt/tasks/live_query/data_store.rb +0 -33
- data/templates/newgem/VERSION +0 -1
@@ -98,6 +98,7 @@ module Volt
|
|
98
98
|
# Called when the next template is ready to render
|
99
99
|
def render_next_template(full_path, path)
|
100
100
|
begin
|
101
|
+
# stop_waiting_for_load
|
101
102
|
remove_current_controller_and_template
|
102
103
|
|
103
104
|
# Switch the current template
|
@@ -107,7 +108,6 @@ module Volt
|
|
107
108
|
# Also track the current controller directly
|
108
109
|
@controller = @current_controller_handler.controller if full_path
|
109
110
|
|
110
|
-
@waiting_for_load = nil
|
111
111
|
render_template(full_path || path)
|
112
112
|
rescue => e
|
113
113
|
Volt.logger.error("Error during render of template at #{path}: #{e.inspect}")
|
@@ -115,6 +115,13 @@ module Volt
|
|
115
115
|
end
|
116
116
|
end
|
117
117
|
|
118
|
+
def stop_waiting_for_load
|
119
|
+
if @waiting_for_load
|
120
|
+
@waiting_for_load.stop
|
121
|
+
@waiting_for_load = nil
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
118
125
|
# On the next tick, we clear the grouped controller so that any changes to template paths
|
119
126
|
# will create a new controller and trigger the action.
|
120
127
|
def queue_clear_grouped_controller
|
@@ -164,9 +171,7 @@ module Volt
|
|
164
171
|
def remove_starting_controller
|
165
172
|
# Clear any previously running wait for loads. This is for when the path changes
|
166
173
|
# before the view actually renders.
|
167
|
-
|
168
|
-
@waiting_for_load.stop
|
169
|
-
end
|
174
|
+
stop_waiting_for_load
|
170
175
|
|
171
176
|
if @starting_controller_handler
|
172
177
|
# Only call the after_..._removed because the dom never loaded.
|
@@ -181,8 +186,7 @@ module Volt
|
|
181
186
|
args = [SubContext.new(@arguments, nil, true)]
|
182
187
|
|
183
188
|
# get the controller class and action
|
184
|
-
controller_class, action =
|
185
|
-
controller_class ||= ModelController
|
189
|
+
controller_class, action = ControllerHandler.get_controller_and_action(controller_path)
|
186
190
|
|
187
191
|
generated_new = false
|
188
192
|
new_controller = Proc.new do
|
@@ -255,29 +259,5 @@ module Volt
|
|
255
259
|
|
256
260
|
super
|
257
261
|
end
|
258
|
-
|
259
|
-
private
|
260
|
-
# Fetch the controller class
|
261
|
-
def get_controller(controller_path)
|
262
|
-
raise "Invalid controller path: #{controller_path.inspect}" unless controller_path && controller_path.size > 0
|
263
|
-
|
264
|
-
action = controller_path[-1]
|
265
|
-
|
266
|
-
# Get the constant parts
|
267
|
-
parts = controller_path[0..-2].map { |v| v.tr('-', '_').camelize }
|
268
|
-
|
269
|
-
# Do const lookups starting at object and working our way down.
|
270
|
-
# So Volt::ProgressBar would lookup Volt, then ProgressBar on Volt.
|
271
|
-
obj = Object
|
272
|
-
parts.each do |part|
|
273
|
-
if obj.const_defined?(part)
|
274
|
-
obj = obj.const_get(part)
|
275
|
-
else
|
276
|
-
return nil
|
277
|
-
end
|
278
|
-
end
|
279
|
-
|
280
|
-
[obj, action]
|
281
|
-
end
|
282
262
|
end
|
283
263
|
end
|
@@ -27,7 +27,7 @@ module Volt
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def handle(event_name, event, target)
|
30
|
-
element =
|
30
|
+
element = `$(#{target})`
|
31
31
|
|
32
32
|
loop do
|
33
33
|
# Lookup the handler, make sure to not assume the group
|
@@ -35,7 +35,10 @@ module Volt
|
|
35
35
|
# TODO: Sometimes the event doesn't exist, but we still get
|
36
36
|
# an event.
|
37
37
|
handlers = @events[event_name]
|
38
|
-
|
38
|
+
|
39
|
+
element_id = `(element && element[0] && element[0].id) || ''`
|
40
|
+
|
41
|
+
handlers = handlers[element_id] if handlers
|
39
42
|
|
40
43
|
if handlers
|
41
44
|
handlers.values.each do |handler|
|
@@ -44,10 +47,10 @@ module Volt
|
|
44
47
|
end
|
45
48
|
end
|
46
49
|
|
47
|
-
if element.
|
50
|
+
if `element.length` == 0
|
48
51
|
break
|
49
52
|
else
|
50
|
-
element = element.parent
|
53
|
+
`element = element.parent()`
|
51
54
|
end
|
52
55
|
end
|
53
56
|
|
data/lib/volt/page/page.rb
CHANGED
@@ -1,7 +1,4 @@
|
|
1
1
|
require 'opal'
|
2
|
-
if RUBY_PLATFORM == 'opal'
|
3
|
-
require 'opal-jquery'
|
4
|
-
end
|
5
2
|
require 'volt/models'
|
6
3
|
require 'volt/controllers/model_controller'
|
7
4
|
require 'volt/tasks/task_handler'
|
@@ -33,7 +30,7 @@ require 'volt/page/tasks'
|
|
33
30
|
|
34
31
|
module Volt
|
35
32
|
class Page
|
36
|
-
attr_reader :url, :params, :page, :
|
33
|
+
attr_reader :url, :params, :page, :routes, :events
|
37
34
|
|
38
35
|
def initialize
|
39
36
|
# Run the code to setup the page
|
@@ -42,6 +39,7 @@ module Volt
|
|
42
39
|
@url = URL.new
|
43
40
|
@params = @url.params
|
44
41
|
@url_tracker = UrlTracker.new(self)
|
42
|
+
@templates = {}
|
45
43
|
|
46
44
|
@events = DocumentEvents.new
|
47
45
|
|
@@ -140,8 +138,6 @@ module Volt
|
|
140
138
|
attr_reader :events
|
141
139
|
|
142
140
|
def add_template(name, template, bindings)
|
143
|
-
@templates ||= {}
|
144
|
-
|
145
141
|
# First template gets priority. The backend will load templates in order so
|
146
142
|
# that local templates come in before gems (so they can be overridden).
|
147
143
|
#
|
@@ -153,6 +149,22 @@ module Volt
|
|
153
149
|
end
|
154
150
|
end
|
155
151
|
|
152
|
+
# On the server, we can delay loading the views until they are actually requeted. This
|
153
|
+
# sets up an instance variable to call to load.
|
154
|
+
def template_loader=(callback)
|
155
|
+
@template_loader = callback
|
156
|
+
end
|
157
|
+
|
158
|
+
def templates
|
159
|
+
if @template_loader
|
160
|
+
# Load the templates
|
161
|
+
@template_loader.call
|
162
|
+
@template_loader = nil
|
163
|
+
end
|
164
|
+
|
165
|
+
@templates
|
166
|
+
end
|
167
|
+
|
156
168
|
def add_routes(&block)
|
157
169
|
@routes ||= Routes.new
|
158
170
|
@routes.define(&block)
|
@@ -161,7 +173,7 @@ module Volt
|
|
161
173
|
|
162
174
|
def start
|
163
175
|
# Setup to render template
|
164
|
-
|
176
|
+
`$('body').html('<!-- $CONTENT --><!-- $/CONTENT -->');`
|
165
177
|
|
166
178
|
load_stored_page
|
167
179
|
|
@@ -208,12 +220,6 @@ module Volt
|
|
208
220
|
if Volt.client?
|
209
221
|
$page = Page.new
|
210
222
|
|
211
|
-
# Call start once the page is loaded
|
212
|
-
# Document.ready? do
|
213
|
-
# $page.start
|
214
|
-
# end
|
215
|
-
|
216
|
-
# For some reason Document.ready? (using opal-jquery) quit working.
|
217
223
|
`$(document).ready(function() {`
|
218
224
|
$page.start
|
219
225
|
`});`
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# The PathRenderer is a simple way to render a string of the contents of a view
|
2
|
+
# at the passed in path.
|
3
|
+
|
4
|
+
require 'volt/page/bindings/view_binding/view_lookup_for_path'
|
5
|
+
require 'volt/page/bindings/view_binding/controller_handler'
|
6
|
+
require 'volt/page/string_template_renderer'
|
7
|
+
|
8
|
+
module Volt
|
9
|
+
class ViewLookupException < Exception ; end
|
10
|
+
class PathStringRenderer
|
11
|
+
attr_reader :html
|
12
|
+
def initialize(path, attrs=nil, page=nil, render_from_path=nil)
|
13
|
+
# use the global page if one is not passed in
|
14
|
+
page ||= $page
|
15
|
+
|
16
|
+
# where to do the path lookup from
|
17
|
+
render_from_path ||= "main/main/main/body"
|
18
|
+
|
19
|
+
# Make path into a full path
|
20
|
+
@view_lookup = Volt::ViewLookupForPath.new(page, render_from_path)
|
21
|
+
full_path, controller_path = @view_lookup.path_for_template(path, nil)
|
22
|
+
|
23
|
+
if full_path == nil
|
24
|
+
raise ViewLookupException, "Unable to find view at `#{path}`"
|
25
|
+
end
|
26
|
+
|
27
|
+
controller_class, action = ControllerHandler.get_controller_and_action(controller_path)
|
28
|
+
|
29
|
+
controller = controller_class.new#(SubContext.new(attrs, nil, true))
|
30
|
+
controller.model = SubContext.new(attrs, nil, true)
|
31
|
+
|
32
|
+
renderer = StringTemplateRenderer.new(page, controller, full_path)
|
33
|
+
|
34
|
+
@html = renderer.html
|
35
|
+
|
36
|
+
# remove when done
|
37
|
+
renderer.remove
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
@@ -41,12 +41,15 @@ module Volt
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def insert_anchor_before_end(binding_name)
|
44
|
-
|
44
|
+
binding_str = "<!-- $#{binding_name} --><!-- $/#{binding_name} -->"
|
45
|
+
`$(#{@end_node}).before(#{binding_str})`
|
45
46
|
end
|
46
47
|
|
47
48
|
def insert_anchor_before(binding_name, insert_after_binding)
|
48
49
|
node = find_by_comment("$#{insert_after_binding}")
|
49
|
-
|
50
|
+
|
51
|
+
binding_str = "<!-- $#{binding_name} --><!-- $/#{binding_name} -->"
|
52
|
+
`$(#{node}).before(#{binding_str})`
|
50
53
|
end
|
51
54
|
|
52
55
|
# Takes in an array of dom nodes and replaces the current content
|
@@ -4,18 +4,13 @@ module Volt
|
|
4
4
|
# Create a method to read a reactive value from an instance value. If it
|
5
5
|
# is not setup, create it so it can be updated through the reactive value
|
6
6
|
# at a later point.
|
7
|
-
def __reactive_dependency_get(var_name)
|
8
|
-
value_dep = instance_variable_get(:"@__#{var_name}_dependency")
|
9
|
-
value_dep ||= instance_variable_set(:"@__#{var_name}_dependency", Dependency.new)
|
10
|
-
end
|
11
|
-
|
12
7
|
def reactive_reader(*names)
|
13
8
|
names.each do |name|
|
14
9
|
var_name = :"@#{name}"
|
15
10
|
define_method(name.to_sym) do
|
16
11
|
value = instance_variable_get(var_name)
|
17
12
|
|
18
|
-
|
13
|
+
__reactive_dependency_get(name).depend
|
19
14
|
|
20
15
|
value
|
21
16
|
end
|
@@ -28,7 +23,7 @@ module Volt
|
|
28
23
|
define_method("#{name}=") do |new_value|
|
29
24
|
instance_variable_set(var_name, new_value)
|
30
25
|
|
31
|
-
|
26
|
+
__reactive_dependency_get(name).changed!
|
32
27
|
end
|
33
28
|
end
|
34
29
|
end
|
@@ -42,5 +37,11 @@ module Volt
|
|
42
37
|
def self.included(base)
|
43
38
|
base.send :extend, ClassMethods
|
44
39
|
end
|
40
|
+
|
41
|
+
def __reactive_dependency_get(var_name)
|
42
|
+
value_dep = instance_variable_get(:"@__#{var_name}_dependency")
|
43
|
+
value_dep ||= instance_variable_set(:"@__#{var_name}_dependency", Dependency.new)
|
44
|
+
end
|
45
|
+
|
45
46
|
end
|
46
47
|
end
|
@@ -18,13 +18,13 @@ module Volt
|
|
18
18
|
# TODO: Sanatize template path
|
19
19
|
component_name = path.gsub(/^\/components\//, '').gsub(/[.](js|map)$/, '')
|
20
20
|
|
21
|
-
javascript_code = compile_for_component(component_name, request_source_map)
|
21
|
+
javascript_code = compile_for_component(component_name, true, request_source_map)
|
22
22
|
|
23
23
|
[200, { 'Content-Type' => 'application/javascript; charset=utf-8' }, StringIO.new(javascript_code)]
|
24
24
|
end
|
25
25
|
|
26
|
-
def compile_for_component(component_name, map=false)
|
27
|
-
code = ComponentCode.new(component_name, @component_paths).code
|
26
|
+
def compile_for_component(component_name, for_client, map=false)
|
27
|
+
code = ComponentCode.new(component_name, @component_paths, for_client).code
|
28
28
|
|
29
29
|
# Compile the code
|
30
30
|
# javascript_code = Opal.compile(code)
|
@@ -16,24 +16,33 @@ module Volt
|
|
16
16
|
code = generate_routes_code + generate_view_code
|
17
17
|
if @client
|
18
18
|
# On the backend, we just need the views
|
19
|
-
code << generate_controller_code + generate_model_code + generate_tasks_code
|
19
|
+
code << generate_controller_code + generate_model_code + generate_tasks_code + generate_initializers_code
|
20
20
|
end
|
21
21
|
|
22
22
|
code
|
23
23
|
end
|
24
24
|
|
25
25
|
def page_reference
|
26
|
-
|
26
|
+
if @client
|
27
|
+
'$page'
|
28
|
+
else
|
29
|
+
'page'
|
30
|
+
end
|
27
31
|
end
|
28
32
|
|
29
33
|
def generate_view_code
|
30
34
|
code = ''
|
31
35
|
views_path = "#{@component_path}/views/"
|
32
36
|
|
37
|
+
exts = ['html']
|
38
|
+
|
39
|
+
# Only load email templates on the server
|
40
|
+
exts << 'email' unless @client
|
41
|
+
|
33
42
|
# Load all templates in the folder
|
34
|
-
Dir["#{views_path}*/*.
|
43
|
+
Dir["#{views_path}*/*.{#{exts.join(',')}}"].sort.each do |view_path|
|
35
44
|
# Get the path for the template, supports templates in folders
|
36
|
-
template_path = view_path[views_path.size
|
45
|
+
template_path = view_path[views_path.size..-1].gsub(/[.](#{exts.join('|')})$/, '')
|
37
46
|
template_path = "#{@component_name}/#{template_path}"
|
38
47
|
|
39
48
|
all_templates = ViewParser.new(File.read(view_path), template_path)
|
@@ -96,8 +105,25 @@ module Volt
|
|
96
105
|
|
97
106
|
def generate_tasks_code
|
98
107
|
Task.known_handlers.map do |handler|
|
99
|
-
|
100
|
-
|
108
|
+
# Split into modules and class
|
109
|
+
klass_parts = handler.name.split('::')
|
110
|
+
|
111
|
+
# Start with the inner class
|
112
|
+
parts = ["class #{klass_parts.pop} < Volt::Task; end"]
|
113
|
+
|
114
|
+
# Work backwards on the modules
|
115
|
+
klass_parts.reverse.each do |kpart|
|
116
|
+
parts.unshift("module #{kpart}")
|
117
|
+
parts.push("end")
|
118
|
+
end
|
119
|
+
|
120
|
+
# Combine the parts
|
121
|
+
parts.join("\n")
|
122
|
+
end.join "\n" # combine all into one string
|
123
|
+
end
|
124
|
+
|
125
|
+
def generate_initializers_code
|
126
|
+
"\nrequire_tree '#{@component_path}/config/initializers/'\n"
|
101
127
|
end
|
102
128
|
end
|
103
129
|
end
|
@@ -63,7 +63,7 @@ module Volt
|
|
63
63
|
|
64
64
|
# Set the drb object locally
|
65
65
|
@dispatcher = Dispatcher.new
|
66
|
-
drb_object = DRb.start_service(
|
66
|
+
drb_object = DRb.start_service('drbunix:', [self, @dispatcher])
|
67
67
|
|
68
68
|
@writer.puts(drb_object.uri)
|
69
69
|
|
@@ -122,7 +122,9 @@ module Volt
|
|
122
122
|
if @exiting
|
123
123
|
[500, {}, 'Server Exiting']
|
124
124
|
else
|
125
|
-
@server_proxy.call_on_child(env)
|
125
|
+
status, headers, body_str = @server_proxy.call_on_child(env)
|
126
|
+
|
127
|
+
[status, headers, StringIO.new(body_str)]
|
126
128
|
end
|
127
129
|
end
|
128
130
|
end
|
@@ -8,7 +8,11 @@ module Volt
|
|
8
8
|
@included_components = {}
|
9
9
|
@components = []
|
10
10
|
|
11
|
-
|
11
|
+
# Include each of the default included components
|
12
|
+
Volt.config.default_components.each do |def_comp_name|
|
13
|
+
component(def_comp_name)
|
14
|
+
end
|
15
|
+
|
12
16
|
component(component_name)
|
13
17
|
end
|
14
18
|
|
@@ -55,7 +55,7 @@ module Volt
|
|
55
55
|
end
|
56
56
|
|
57
57
|
# Makes each components classes available on the load path, require classes.
|
58
|
-
def require_in_components
|
58
|
+
def require_in_components(page)
|
59
59
|
if RUBY_PLATFORM == 'opal'
|
60
60
|
else
|
61
61
|
app_folders do |app_folder|
|
@@ -68,15 +68,16 @@ module Volt
|
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
|
-
|
71
|
+
# Delay the loading of views
|
72
|
+
page.template_loader = -> { load_views_and_routes(page) }
|
72
73
|
end
|
73
74
|
end
|
74
75
|
|
75
|
-
def load_views_and_routes
|
76
|
+
def load_views_and_routes(page)
|
76
77
|
component_names = []
|
77
78
|
app_folders do |app_folder|
|
78
79
|
Dir["#{app_folder}/*"].map { |cp| cp[/[^\/]+$/] }.each do |component_name|
|
79
|
-
component_names << component_name
|
80
|
+
component_names << component_name
|
80
81
|
end
|
81
82
|
end
|
82
83
|
|
@@ -84,6 +85,7 @@ module Volt
|
|
84
85
|
# TODO: Nested components listed twice are are loaded multiple times
|
85
86
|
component_names.uniq.each do |component_name|
|
86
87
|
code = Volt::ComponentCode.new(component_name, self, false).code
|
88
|
+
# Evaluate returned code, the ```page``` variable is set for access.
|
87
89
|
eval(code)
|
88
90
|
end
|
89
91
|
end
|
@@ -1,8 +1,11 @@
|
|
1
1
|
require 'volt/server/rack/source_map_server'
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
2
|
+
|
3
|
+
# There is currently a weird issue with therubyracer
|
4
|
+
# https://github.com/rails/execjs/issues/15
|
5
|
+
# https://github.com/middleman/middleman/issues/1367
|
6
|
+
#
|
7
|
+
# To get around this, we just force Node for the time being
|
8
|
+
ENV['EXECJS_RUNTIME'] = 'Node'
|
6
9
|
|
7
10
|
# Sets up the maps for the opal assets, and source maps if enabled.
|
8
11
|
module Volt
|
@@ -43,10 +46,16 @@ module Volt
|
|
43
46
|
|
44
47
|
environment.cache = Sprockets::Cache::FileStore.new('./tmp')
|
45
48
|
|
46
|
-
|
47
|
-
|
49
|
+
# Compress in production
|
50
|
+
if Volt.config.compress_javascript
|
51
|
+
require 'uglifier'
|
48
52
|
environment.js_compressor = Sprockets::UglifierCompressor
|
49
|
-
|
53
|
+
end
|
54
|
+
|
55
|
+
if Volt.config.compress_css
|
56
|
+
require 'ruby-clean-css'
|
57
|
+
require 'ruby-clean-css/sprockets'
|
58
|
+
RubyCleanCSS::Sprockets.register(environment)
|
50
59
|
end
|
51
60
|
|
52
61
|
server.append_path(app_path)
|
@@ -61,10 +70,6 @@ module Volt
|
|
61
70
|
server.append_path(path)
|
62
71
|
end
|
63
72
|
|
64
|
-
# opal-jquery gem
|
65
|
-
spec = Gem::Specification.find_by_name('opal-jquery')
|
66
|
-
server.append_path(spec.gem_dir + '/lib')
|
67
|
-
|
68
73
|
builder.map '/assets' do
|
69
74
|
run server
|
70
75
|
end
|
@@ -5,7 +5,7 @@ class QuietCommonLogger < Rack::CommonLogger
|
|
5
5
|
@@ignore_extensions = %w(png jpg jpeg ico gif woff tff svg eot css js)
|
6
6
|
|
7
7
|
def call(env)
|
8
|
-
path = env['
|
8
|
+
path = env['PATH_INFO']
|
9
9
|
began_at = Time.now
|
10
10
|
status, header, body = @app.call(env)
|
11
11
|
header = Utils::HeaderHash.new(header)
|
data/lib/volt/server.rb
CHANGED
@@ -35,7 +35,7 @@ module Rack
|
|
35
35
|
def call(env)
|
36
36
|
status, headers, body = @app.call(env)
|
37
37
|
|
38
|
-
if status == 304 && env['HTTP_CONNECTION'].downcase == 'keep-alive'
|
38
|
+
if status == 304 && env['HTTP_CONNECTION'] && env['HTTP_CONNECTION'].downcase == 'keep-alive'
|
39
39
|
headers['Connection'] = 'keep-alive'
|
40
40
|
end
|
41
41
|
|
data/lib/volt/spec/setup.rb
CHANGED
data/lib/volt/version.rb
ADDED
data/lib/volt/volt/app.rb
CHANGED
@@ -1,11 +1,21 @@
|
|
1
1
|
module Volt
|
2
2
|
class App
|
3
|
-
attr_reader :component_paths, :router
|
3
|
+
attr_reader :component_paths, :router, :page
|
4
4
|
|
5
5
|
def initialize(app_path)
|
6
6
|
# Setup root path
|
7
7
|
Volt.root = app_path
|
8
8
|
|
9
|
+
# Run the app config to load all users config files
|
10
|
+
unless RUBY_PLATFORM == 'opal'
|
11
|
+
if Volt.server?
|
12
|
+
@page = Page.new
|
13
|
+
|
14
|
+
# Setup a global for now
|
15
|
+
$page = @page unless defined?($page)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
9
19
|
# Require in app and initializers
|
10
20
|
unless RUBY_PLATFORM == 'opal'
|
11
21
|
Volt.run_app_and_initializers
|
@@ -13,7 +23,7 @@ module Volt
|
|
13
23
|
|
14
24
|
# Load component paths
|
15
25
|
@component_paths = ComponentPaths.new(app_path)
|
16
|
-
@component_paths.require_in_components
|
26
|
+
@component_paths.require_in_components(@page || $page)
|
17
27
|
|
18
28
|
unless RUBY_PLATFORM == 'opal'
|
19
29
|
setup_router
|
@@ -7,11 +7,9 @@ describe 'http endpoints', type: :feature, sauce: true do
|
|
7
7
|
end
|
8
8
|
|
9
9
|
it 'should have access to the store' do
|
10
|
-
|
11
|
-
$page.store._simple_http_tests << { name: 'hello' }
|
10
|
+
store._simple_http_tests << { name: 'hello' }
|
12
11
|
visit '/simple_http/store'
|
13
12
|
expect(page).to have_content('You had me at hello')
|
14
|
-
DataStore.new.drop_database
|
15
13
|
end
|
16
14
|
|
17
15
|
it 'should upload and store a file' do
|
@@ -1,16 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe 'user accounts', type: :feature, sauce: true do
|
4
|
-
before(:each) do
|
5
|
-
# Clear out db
|
6
|
-
DataStore.new.drop_database
|
7
|
-
end
|
8
|
-
|
9
|
-
after(:each) do
|
10
|
-
# Clear out db
|
11
|
-
DataStore.new.drop_database
|
12
|
-
end
|
13
|
-
|
14
4
|
it 'should create an account' do
|
15
5
|
visit '/'
|
16
6
|
|
@@ -11,9 +11,6 @@ end
|
|
11
11
|
describe Volt::Associations do
|
12
12
|
if RUBY_PLATFORM != 'opal'
|
13
13
|
before do
|
14
|
-
# DataStore.new.drop_database
|
15
|
-
# $page.instance_variable_set('@store', nil)
|
16
|
-
|
17
14
|
store._people! << {name: 'Jimmy'}
|
18
15
|
@person = store._people[0]
|
19
16
|
@person._addresses! << {city: 'Bozeman'}
|
data/spec/models/model_spec.rb
CHANGED
@@ -540,5 +540,18 @@ describe Volt::Model do
|
|
540
540
|
|
541
541
|
expect(count).to eq(1)
|
542
542
|
end
|
543
|
+
|
544
|
+
it 'should query twice and return twice' do
|
545
|
+
store._items << {name: 'One'}
|
546
|
+
store._items << {name: 'Two'}
|
547
|
+
|
548
|
+
a = store._items.fetch.sync
|
549
|
+
b = store._items.fetch.sync
|
550
|
+
|
551
|
+
expect(a.size).to eq(2)
|
552
|
+
expect(b.size).to eq(2)
|
553
|
+
|
554
|
+
expect(a.to_a).to eq(b.to_a)
|
555
|
+
end
|
543
556
|
end
|
544
557
|
end
|