volt 0.9.5.pre1 → 0.9.5.pre2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +2 -0
- data/README.md +5 -1
- data/lib/volt/cli.rb +2 -2
- data/lib/volt/models/associations.rb +11 -4
- data/lib/volt/server/component_templates.rb +23 -66
- data/lib/volt/server/forking_server.rb +25 -0
- data/lib/volt/server/html_parser/view_parser.rb +20 -0
- data/lib/volt/server/rack/quiet_common_logger.rb +3 -1
- data/lib/volt/server/template_handlers/preprocessors.rb +33 -0
- data/lib/volt/server/template_handlers/sprockets_component_handler.rb +31 -28
- data/lib/volt/server/template_handlers/view_processor.rb +77 -0
- data/lib/volt/tasks/dispatcher.rb +17 -0
- data/lib/volt/version.rb +1 -1
- data/lib/volt/volt/app.rb +6 -0
- data/spec/models/associations_spec.rb +2 -0
- data/spec/server/component_templates_spec.rb +4 -4
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a5ad03d3fbc695e769889222bdd6657b969c8f0c
|
4
|
+
data.tar.gz: 71b3134705638ac491e1cdb37859aefafe44d159
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 97fb9fafd89425cd8a137b9758ebb488a289af1f88b25b4b893693852138a6325e354863d4a737155191f386166af62b54d7e88799b3feef17e74f3f9ef5a9dc
|
7
|
+
data.tar.gz: 8ea29521ba220cfdf866db220bca6e6afc62c2e4086fe4d72b10cbc3964ed7545974ba199ba03a0514c1c620515bc3e139b94506214b6910934dd5a6871823e6
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,8 @@
|
|
3
3
|
## 0.9.5
|
4
4
|
### Added
|
5
5
|
- You can now disable auto-import of JS/CSS with ```disable_auto_import``` in a dependencies.rb file
|
6
|
+
- Opal was upgraded to 0.8, which brings sourcemaps back (yah!)
|
7
|
+
- Page load performance was improved, and more of sprockets was used for component loading.
|
6
8
|
|
7
9
|
## 0.9.4
|
8
10
|
### Lingo Change
|
data/README.md
CHANGED
@@ -41,7 +41,7 @@ Rick Carlino has been putting together some great volt tutorial videos also.
|
|
41
41
|
- [Build a Realtime Chat App with Volt](http://datamelon.io/blog/2015/building-a-chat-app-in-volt.html)
|
42
42
|
- [Understanding Volt Views](http://datamelon.io/blog/2015/understanding-views-in-volt-with-a-card-game.html)
|
43
43
|
|
44
|
-
@
|
44
|
+
@ahnbizcad maintains a [playlist of Volt related videos](https://www.youtube.com/watch?v=McxtO8ybxy8&list=PLmQFeDKFCPXatHb-zEXwfeMH01DPiZjP7).
|
45
45
|
|
46
46
|
# Getting Help
|
47
47
|
|
@@ -58,3 +58,7 @@ VoltFramework is currently a labor of love mainly built by a small group of core
|
|
58
58
|
[![Pledgie](https://pledgie.com/campaigns/26731.png?skin_name=chrome)](https://pledgie.com/campaigns/26731)
|
59
59
|
|
60
60
|
Bitcoins can also be sent to 1AYiL3MiSVe2QFyexzozUvFFH7uGCJgJMZ
|
61
|
+
|
62
|
+
|
63
|
+
Timings:
|
64
|
+
- view:
|
data/lib/volt/cli.rb
CHANGED
@@ -67,8 +67,8 @@ module Volt
|
|
67
67
|
# TODO: this is a work around for a bug when switching between
|
68
68
|
# source maps and non-source maps.
|
69
69
|
if File.exist?('config.ru') && File.exist?('Gemfile')
|
70
|
-
FileUtils.rm_rf('tmp/sass')
|
71
|
-
FileUtils.rm_rf('tmp/sprockets')
|
70
|
+
# FileUtils.rm_rf('tmp/sass')
|
71
|
+
# FileUtils.rm_rf('tmp/sprockets')
|
72
72
|
else
|
73
73
|
say('Current folder is not a Volt project', :red)
|
74
74
|
return
|
@@ -2,7 +2,7 @@ module Volt
|
|
2
2
|
module Associations
|
3
3
|
module ClassMethods
|
4
4
|
def belongs_to(method_name, options = {})
|
5
|
-
collection ||= options.fetch(:collection, method_name)
|
5
|
+
collection ||= options.fetch(:collection, method_name).pluralize
|
6
6
|
foreign_key ||= options.fetch(:foreign_key, :id)
|
7
7
|
local_key ||= options.fetch(:local_key, "#{method_name}_id")
|
8
8
|
|
@@ -16,7 +16,7 @@ module Volt
|
|
16
16
|
lookup_key = get(local_key)
|
17
17
|
|
18
18
|
# Return a promise for the belongs_to
|
19
|
-
root.get(collection
|
19
|
+
root.get(collection).where(foreign_key => lookup_key).first
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
@@ -28,9 +28,16 @@ module Volt
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
-
def has_many(method_name,
|
31
|
+
def has_many(method_name, options = {})
|
32
|
+
collection ||= options.fetch(:collection, method_name).pluralize
|
33
|
+
|
34
|
+
# Use the underscored current class name as the something_id.
|
35
|
+
foreign_key ||= options.fetch(:foreign_key, "#{to_s.underscore.singularize}_id")
|
36
|
+
local_key ||= options.fetch(:local_key, :id)
|
37
|
+
|
32
38
|
define_method(method_name) do
|
33
|
-
get(
|
39
|
+
lookup_key = get(local_key)
|
40
|
+
get(collection).where(foreign_key => lookup_key)
|
34
41
|
end
|
35
42
|
end
|
36
43
|
|
@@ -1,5 +1,7 @@
|
|
1
1
|
require 'volt/server/html_parser/view_parser'
|
2
2
|
require 'volt/tasks/task'
|
3
|
+
require 'volt/server/template_handlers/preprocessors'
|
4
|
+
|
3
5
|
|
4
6
|
# Initialize with the path to a component and returns all the front-end
|
5
7
|
# setup code (for controllers, models, views, and routes)
|
@@ -11,39 +13,7 @@ module Volt
|
|
11
13
|
end
|
12
14
|
|
13
15
|
class ComponentTemplates
|
14
|
-
|
15
|
-
module Handlers #:nodoc:
|
16
|
-
# Setup default handler on extend
|
17
|
-
def self.extended(base)
|
18
|
-
base.register_template_handler :html, BasicHandler.new
|
19
|
-
base.register_template_handler :email, BasicHandler.new
|
20
|
-
end
|
21
|
-
|
22
|
-
@@template_handlers = {}
|
23
|
-
|
24
|
-
def self.extensions
|
25
|
-
@@template_handlers.keys
|
26
|
-
end
|
27
|
-
|
28
|
-
# Register an object that knows how to handle template files with the given
|
29
|
-
# extensions. This can be used to implement new template types.
|
30
|
-
# The handler must respond to +:call+, which will be passed the template
|
31
|
-
# and should return the rendered template as a String.
|
32
|
-
def register_template_handler(extension, handler)
|
33
|
-
@@template_handlers[extension.to_sym] = handler
|
34
|
-
end
|
35
|
-
|
36
|
-
def registered_template_handler(extension)
|
37
|
-
extension && @@template_handlers[extension.to_sym]
|
38
|
-
end
|
39
|
-
|
40
|
-
def handler_for_extension(extension)
|
41
|
-
registered_template_handler(extension)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
extend ComponentTemplates::Handlers
|
46
|
-
|
16
|
+
extend ComponentTemplates::Preprocessors
|
47
17
|
|
48
18
|
# client is if we are generating for the client or backend
|
49
19
|
def initialize(component_path, component_name, client = true)
|
@@ -75,52 +45,39 @@ module Volt
|
|
75
45
|
code = ''
|
76
46
|
views_path = "#{@component_path}/views/"
|
77
47
|
|
78
|
-
exts =
|
48
|
+
exts = Preprocessors.extensions
|
79
49
|
|
80
50
|
# Load all templates in the folder
|
81
51
|
Dir["#{views_path}*/*.{#{exts.join(',')}}"].sort.each do |view_path|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
# file extension
|
86
|
-
format = File.extname(view_path).downcase.delete('.').to_sym
|
87
|
-
|
88
|
-
# Get the path for the template, supports templates in folders
|
89
|
-
template_path = view_path[views_path.size..-1].gsub(/[.](#{exts.join('|')})$/, '')
|
90
|
-
template_path = "#{@component_name}/#{template_path}"
|
52
|
+
if @client
|
53
|
+
require_path = view_path.split('/')[-4..-1].join('/').gsub(/[.][^.]*$/, '')
|
91
54
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
55
|
+
# On the client side, we can just require the file and let sprockets
|
56
|
+
# handle things.
|
57
|
+
code << "\nrequire '#{require_path}'\n"
|
58
|
+
else
|
59
|
+
# On the sever side, we eval the compiled code
|
60
|
+
path_parts = view_path.scan(/([^\/]+)\/([^\/]+)\/[^\/]+\/([^\/]+)[.](html|email)$/)
|
61
|
+
component_name, controller_name, view, _ = path_parts[0]
|
99
62
|
|
100
|
-
|
63
|
+
# file extension
|
64
|
+
format = File.extname(view_path).downcase.delete('.').to_sym
|
101
65
|
|
102
|
-
|
103
|
-
|
104
|
-
|
66
|
+
# Get the path for the template, supports templates in folders
|
67
|
+
template_path = view_path[views_path.size..-1].gsub(/[.](#{exts.join('|')})$/, '')
|
68
|
+
template_path = "#{@component_name}/#{template_path}"
|
105
69
|
|
106
|
-
|
107
|
-
template['bindings'].each_pair do |key, value|
|
108
|
-
binding_code << "#{key.inspect} => [#{value.join(', ')}]"
|
109
|
-
end
|
110
|
-
end
|
70
|
+
html = File.read(view_path)
|
111
71
|
|
112
|
-
|
72
|
+
if handler = ComponentTemplates.handler_for_extension(format)
|
73
|
+
html = handler.call(html)
|
113
74
|
|
114
|
-
code <<
|
115
|
-
# template_calls << "template(#{name.inspect}, #{template['html'].inspect}, #{binding_code})"
|
75
|
+
code << ViewParser.new(html, template_path).code(app_reference)
|
116
76
|
end
|
117
77
|
end
|
118
|
-
|
119
|
-
# puts "module #{component_name.camelize}\n class #{controller_name.camelize}\n class VoltTemplates < VoltTemplates\n #{template_calls.join("\n")}\n end\n end\nend"
|
120
78
|
end
|
121
79
|
|
122
80
|
code
|
123
|
-
|
124
81
|
end
|
125
82
|
|
126
83
|
def generate_controller_code
|
@@ -141,7 +98,7 @@ module Volt
|
|
141
98
|
|
142
99
|
controllers.each do |path|
|
143
100
|
if File.exists?(path)
|
144
|
-
code << "
|
101
|
+
code << "\nrequire '#{localize_path(path)}'\n"
|
145
102
|
else
|
146
103
|
# parts = path.scan(/([^\/]+)\/controllers\/([^\/]+)_controller[.]rb$/)
|
147
104
|
# component, controller = parts[0]
|
@@ -31,6 +31,9 @@ module Volt
|
|
31
31
|
|
32
32
|
@server = server
|
33
33
|
|
34
|
+
# Set the mod time on boot
|
35
|
+
update_mod_time
|
36
|
+
|
34
37
|
start_child
|
35
38
|
end
|
36
39
|
|
@@ -216,6 +219,14 @@ module Volt
|
|
216
219
|
|
217
220
|
Volt.logger.log_with_color(msg, :light_blue)
|
218
221
|
|
222
|
+
|
223
|
+
# Figure out if any views or routes were changed:
|
224
|
+
# TODO: Might want to only check for /config/ under the CWD
|
225
|
+
if changed_files.any? {|path| path =~ /\/config\// }
|
226
|
+
update_mod_time
|
227
|
+
sync_mod_time
|
228
|
+
end
|
229
|
+
|
219
230
|
begin
|
220
231
|
SocketConnectionHandler.send_message_all(nil, 'reload')
|
221
232
|
rescue => e
|
@@ -227,11 +238,25 @@ module Volt
|
|
227
238
|
@child_lock.with_write_lock do
|
228
239
|
stop_child
|
229
240
|
start_child
|
241
|
+
sync_mod_time
|
230
242
|
end
|
231
243
|
end
|
232
244
|
end
|
233
245
|
|
246
|
+
def update_mod_time
|
247
|
+
@last_mod_time = Time.now.to_i.to_s
|
248
|
+
end
|
249
|
+
|
250
|
+
def sync_mod_time
|
251
|
+
disp = SocketConnectionHandler.dispatcher
|
252
|
+
|
253
|
+
unless disp.is_a?(ErrorDispatcher)
|
254
|
+
disp.component_modified(@last_mod_time)
|
255
|
+
end
|
256
|
+
end
|
257
|
+
|
234
258
|
def start_change_listener
|
259
|
+
sync_mod_time
|
235
260
|
# Setup the listeners for file changes
|
236
261
|
@listener = Listen.to("#{@server.app_path}/") do |modified, added, removed|
|
237
262
|
Thread.new do
|
@@ -42,5 +42,25 @@ module Volt
|
|
42
42
|
|
43
43
|
templates
|
44
44
|
end
|
45
|
+
|
46
|
+
# Generate code for the view that can be evaled.
|
47
|
+
def code(app_reference)
|
48
|
+
code = ''
|
49
|
+
templates.each_pair do |name, template|
|
50
|
+
binding_code = []
|
51
|
+
|
52
|
+
if template['bindings']
|
53
|
+
template['bindings'].each_pair do |key, value|
|
54
|
+
binding_code << "#{key.inspect} => [#{value.join(', ')}]"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
binding_code = "{#{binding_code.join(', ')}}"
|
59
|
+
|
60
|
+
code << "#{app_reference}.add_template(#{name.inspect}, #{template['html'].inspect}, #{binding_code})\n"
|
61
|
+
end
|
62
|
+
|
63
|
+
code
|
64
|
+
end
|
45
65
|
end
|
46
66
|
end
|
@@ -20,7 +20,9 @@ class QuietCommonLogger < Rack::CommonLogger
|
|
20
20
|
|
21
21
|
body = BodyProxy.new(body) do
|
22
22
|
# Don't log on ignored extensions
|
23
|
-
if !@@ignore_extensions.include?(ext) &&
|
23
|
+
if !@@ignore_extensions.include?(ext) &&
|
24
|
+
!path.start_with?('/__OPAL_SOURCE_MAPS__/') &&
|
25
|
+
!@logged
|
24
26
|
log(env, status, header, began_at)
|
25
27
|
end
|
26
28
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Volt
|
2
|
+
class ComponentTemplates
|
3
|
+
module Preprocessors #:nodoc:
|
4
|
+
# Setup default handler on extend
|
5
|
+
def self.extended(base)
|
6
|
+
base.register_template_handler :html, BasicHandler.new
|
7
|
+
base.register_template_handler :email, BasicHandler.new
|
8
|
+
end
|
9
|
+
|
10
|
+
@@template_handlers = {}
|
11
|
+
|
12
|
+
def self.extensions
|
13
|
+
@@template_handlers.keys
|
14
|
+
end
|
15
|
+
|
16
|
+
# Register an object that knows how to handle template files with the given
|
17
|
+
# extensions. This can be used to implement new template types.
|
18
|
+
# The handler must respond to +:call+, which will be passed the template
|
19
|
+
# and should return the rendered template as a String.
|
20
|
+
def register_template_handler(extension, handler)
|
21
|
+
@@template_handlers[extension.to_sym] = handler
|
22
|
+
end
|
23
|
+
|
24
|
+
def registered_template_handler(extension)
|
25
|
+
extension && @@template_handlers[extension.to_sym]
|
26
|
+
end
|
27
|
+
|
28
|
+
def handler_for_extension(extension)
|
29
|
+
registered_template_handler(extension)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -1,3 +1,6 @@
|
|
1
|
+
require 'volt/server/template_handlers/view_processor'
|
2
|
+
require 'sprockets'
|
3
|
+
|
1
4
|
# This file Monkeypatches sprockets to provide custom file loading (from volt
|
2
5
|
# instead disk) for component root files. These files then require in all parts
|
3
6
|
# or include generated ruby for templates, routes, and tasks.
|
@@ -19,9 +22,9 @@ module Volt
|
|
19
22
|
"stub-digest-#{mtime}"
|
20
23
|
end
|
21
24
|
|
25
|
+
# Get the mtime from the forking server
|
22
26
|
def mtime
|
23
|
-
|
24
|
-
rand(2_000_000_000)
|
27
|
+
Volt::Dispatcher.component_last_modified_time.to_s
|
25
28
|
end
|
26
29
|
end
|
27
30
|
end
|
@@ -45,7 +48,8 @@ module Sprockets
|
|
45
48
|
stats[path] = Volt::StatStub.new
|
46
49
|
|
47
50
|
# Working with a component path
|
48
|
-
|
51
|
+
volt_app = Thread.current['volt_app'] || $volt_app
|
52
|
+
data = Volt::ComponentCode.new(component_name, volt_app.component_paths, true).code
|
49
53
|
else
|
50
54
|
data = env.read_file(input[:filename], input[:content_type])
|
51
55
|
end
|
@@ -72,10 +76,6 @@ module Sprockets
|
|
72
76
|
#
|
73
77
|
# Returns true path exists and is a file.
|
74
78
|
def file?(path)
|
75
|
-
# if path =~ /\/components\/[^.]+[.]rb$/
|
76
|
-
# return true
|
77
|
-
# end
|
78
|
-
|
79
79
|
if stat = self.stat(path)
|
80
80
|
stat.file?
|
81
81
|
elsif path =~ /^#{Volt.root}\/app\/components\/[^\/]+[.]rb$/
|
@@ -85,27 +85,6 @@ module Sprockets
|
|
85
85
|
false
|
86
86
|
end
|
87
87
|
end
|
88
|
-
|
89
|
-
# Public: Like `File.directory?`.
|
90
|
-
#
|
91
|
-
# path - String file path.
|
92
|
-
#
|
93
|
-
# Returns true path exists and is a directory.
|
94
|
-
def directory?(path)
|
95
|
-
# if path == '/Users/ryanstout/Sites/volt/volt/app/components/main'
|
96
|
-
# return true
|
97
|
-
# end
|
98
|
-
|
99
|
-
if stat = self.stat(path)
|
100
|
-
stat.directory?
|
101
|
-
# else
|
102
|
-
elsif path =~ /^#{Volt.root}\/app\/components\/[^\/]+$/
|
103
|
-
# Matches a component
|
104
|
-
return true
|
105
|
-
else
|
106
|
-
false
|
107
|
-
end
|
108
|
-
end
|
109
88
|
end
|
110
89
|
end
|
111
90
|
|
@@ -128,6 +107,30 @@ module Sprockets
|
|
128
107
|
end
|
129
108
|
end
|
130
109
|
|
110
|
+
module Sprockets
|
111
|
+
class Base
|
112
|
+
def file_digest(path)
|
113
|
+
if stat = self.stat(path)
|
114
|
+
# Caveat: Digests are cached by the path's current mtime. Its possible
|
115
|
+
# for a files contents to have changed and its mtime to have been
|
116
|
+
# negligently reset thus appearing as if the file hasn't changed on
|
117
|
+
# disk. Also, the mtime is only read to the nearest second. Its
|
118
|
+
# also possible the file was updated more than once in a given second.
|
119
|
+
cache.fetch("file_digest:#{path}:#{stat.mtime.to_i}") do
|
120
|
+
self.stat_digest(path, stat)
|
121
|
+
end
|
122
|
+
elsif path =~ /^#{Volt.root}\/app\/components\/[^\/]+$/
|
123
|
+
# Return a random mtime
|
124
|
+
# puts "LMT: #{Volt::Dispatcher.last_modified_time.inspect}"
|
125
|
+
mtime = Volt::Dispatcher.component_last_modified_time.to_s
|
126
|
+
|
127
|
+
# puts "STUB: #{mtime}"
|
128
|
+
"stub-digest-#{mtime}"
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
131
134
|
module Sprockets
|
132
135
|
module Resolve
|
133
136
|
def path_matches(load_path, logical_name, logical_basename)
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require 'volt/server/component_templates'
|
2
|
+
require 'opal/sprockets/processor'
|
3
|
+
require 'sprockets'
|
4
|
+
require 'tilt'
|
5
|
+
require 'opal/sprockets/processor'
|
6
|
+
|
7
|
+
module Volt
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
class ViewProcessor < ::Opal::TiltTemplate
|
12
|
+
|
13
|
+
def initialize(client)
|
14
|
+
@client = client
|
15
|
+
end
|
16
|
+
|
17
|
+
def app_reference
|
18
|
+
if @client
|
19
|
+
'Volt.current_app'
|
20
|
+
else
|
21
|
+
'volt_app'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def cache_key
|
26
|
+
@cache_key ||= "#{self.class.name}:0.1".freeze
|
27
|
+
end
|
28
|
+
|
29
|
+
# def evaluate(context, locals, &block)
|
30
|
+
# binding.pry
|
31
|
+
# @data = compile(@data)
|
32
|
+
# super
|
33
|
+
# end
|
34
|
+
|
35
|
+
def call(input)
|
36
|
+
# pp input
|
37
|
+
data = input[:data]
|
38
|
+
|
39
|
+
# input[:accept] = 'application/javascript'
|
40
|
+
# input[:content_type] = 'application/javascript'
|
41
|
+
# input[:environment].content_type = 'application/javascript'
|
42
|
+
input[:cache].fetch([self.cache_key, data]) do
|
43
|
+
filename = input[:filename]
|
44
|
+
# puts input[:data].inspect
|
45
|
+
# Remove all semicolons from source
|
46
|
+
# input[:content_type] = 'application/javascript'
|
47
|
+
compile(filename, input[:data])
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def compile(view_path, html)
|
52
|
+
exts = ComponentTemplates::Preprocessors.extensions
|
53
|
+
template_path = view_path.split('/')[-4..-1].join('/').gsub('/views/', '/').gsub(/[.](#{exts.join('|')})$/, '')
|
54
|
+
|
55
|
+
exts = ComponentTemplates::Preprocessors.extensions
|
56
|
+
|
57
|
+
format = File.extname(view_path).downcase.delete('.').to_sym
|
58
|
+
code = ''
|
59
|
+
|
60
|
+
# Process template if we have a handler for this file type
|
61
|
+
if handler = ComponentTemplates.handler_for_extension(format)
|
62
|
+
html = handler.call(html)
|
63
|
+
|
64
|
+
code = ViewParser.new(html, template_path).code(app_reference)
|
65
|
+
end
|
66
|
+
|
67
|
+
Opal.compile(code)
|
68
|
+
end
|
69
|
+
|
70
|
+
def self.setup
|
71
|
+
sprockets = $volt_app.sprockets
|
72
|
+
sprockets.register_mime_type 'application/vtemplate', extensions: ['.html', '.email']
|
73
|
+
sprockets.register_transformer 'application/vtemplate', 'application/javascript', Volt::ViewProcessor.new(true)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
@@ -30,6 +30,23 @@ module Volt
|
|
30
30
|
@worker_timeout = Volt.config.worker_timeout || 60
|
31
31
|
end
|
32
32
|
|
33
|
+
# Mark the last time of the component modification for caching in sprockets
|
34
|
+
def self.component_modified(time)
|
35
|
+
@last_modified_time = time
|
36
|
+
end
|
37
|
+
|
38
|
+
def component_modified(time)
|
39
|
+
self.class.component_modified(time)
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.component_last_modified_time
|
43
|
+
unless @last_modified_time
|
44
|
+
component_modified(Time.now.to_i.to_s)
|
45
|
+
end
|
46
|
+
|
47
|
+
@last_modified_time
|
48
|
+
end
|
49
|
+
|
33
50
|
# Dispatch takes an incoming Task from the client and runs it on the
|
34
51
|
# server, returning the result to the client.
|
35
52
|
# Tasks returning a promise will wait to return.
|
data/lib/volt/version.rb
CHANGED
data/lib/volt/volt/app.rb
CHANGED
@@ -30,6 +30,7 @@ if RUBY_PLATFORM == 'opal'
|
|
30
30
|
require 'volt/volt/client_setup/browser'
|
31
31
|
else
|
32
32
|
require 'volt/volt/server_setup/app'
|
33
|
+
require 'volt/server/template_handlers/view_processor'
|
33
34
|
end
|
34
35
|
|
35
36
|
module Volt
|
@@ -51,6 +52,9 @@ module Volt
|
|
51
52
|
raise "Volt::App.new requires an app path to boot"
|
52
53
|
end
|
53
54
|
|
55
|
+
# Expand to a full path
|
56
|
+
app_path = File.expand_path(app_path)
|
57
|
+
|
54
58
|
@app_path = app_path
|
55
59
|
$volt_app = self
|
56
60
|
|
@@ -90,6 +94,8 @@ module Volt
|
|
90
94
|
setup_postboot_middleware
|
91
95
|
|
92
96
|
start_message_bus
|
97
|
+
|
98
|
+
Volt::ViewProcessor.setup
|
93
99
|
end
|
94
100
|
end
|
95
101
|
|
@@ -30,6 +30,7 @@ describe Volt::Associations do
|
|
30
30
|
it 'should associate via belongs_to' do
|
31
31
|
address = store.addresses.first.sync
|
32
32
|
|
33
|
+
expect(address.person_id).to eq(@person.id)
|
33
34
|
expect(address.person.sync.id).to eq(@person.id)
|
34
35
|
end
|
35
36
|
|
@@ -83,6 +84,7 @@ describe Volt::Associations do
|
|
83
84
|
it 'should assign the reference_id for has_many' do
|
84
85
|
bob = store.people.create.sync
|
85
86
|
address = bob.addresses.create({:street => '1234 awesome street'})
|
87
|
+
|
86
88
|
expect(bob.addresses[0].sync.person_id).to eq(bob.id)
|
87
89
|
expect(bob.id).to_not eq(nil)
|
88
90
|
end
|
@@ -5,16 +5,16 @@ else
|
|
5
5
|
require 'volt/server/component_templates'
|
6
6
|
|
7
7
|
describe Volt::ComponentTemplates do
|
8
|
-
let(:haml_handler) do
|
8
|
+
let(:haml_handler) do
|
9
9
|
double(:haml_handler)
|
10
10
|
end
|
11
11
|
|
12
12
|
it 'can be extended' do
|
13
|
-
expect( Volt::ComponentTemplates::
|
13
|
+
expect( Volt::ComponentTemplates::Preprocessors.extensions ).to eq([ :html, :email ])
|
14
14
|
|
15
|
-
Volt::ComponentTemplates.register_template_handler(:haml, haml_handler)
|
15
|
+
Volt::ComponentTemplates.register_template_handler(:haml, haml_handler)
|
16
16
|
|
17
|
-
expect( Volt::ComponentTemplates::
|
17
|
+
expect( Volt::ComponentTemplates::Preprocessors.extensions ).to eq([ :html, :email, :haml ])
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
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.9.5.
|
4
|
+
version: 0.9.5.pre2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Stout
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -549,7 +549,9 @@ files:
|
|
549
549
|
- lib/volt/server/rack/source_map_server.rb
|
550
550
|
- lib/volt/server/socket_connection_handler.rb
|
551
551
|
- lib/volt/server/socket_connection_handler_stub.rb
|
552
|
+
- lib/volt/server/template_handlers/preprocessors.rb
|
552
553
|
- lib/volt/server/template_handlers/sprockets_component_handler.rb
|
554
|
+
- lib/volt/server/template_handlers/view_processor.rb
|
553
555
|
- lib/volt/server/websocket/rack_server_adaptor.rb
|
554
556
|
- lib/volt/server/websocket/websocket_handler.rb
|
555
557
|
- lib/volt/spec/capybara.rb
|