volt 0.9.3.pre3 → 0.9.3.pre4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -2
- data/app/volt/models/user.rb +5 -0
- data/app/volt/tasks/store_tasks.rb +2 -2
- data/app/volt/tasks/user_tasks.rb +1 -1
- data/lib/volt/cli/asset_compile.rb +0 -2
- data/lib/volt/cli/generate.rb +8 -3
- data/lib/volt/cli.rb +3 -9
- data/lib/volt/controllers/actions.rb +6 -1
- data/lib/volt/controllers/http_controller.rb +16 -7
- data/lib/volt/controllers/model_controller.rb +21 -0
- data/lib/volt/models/array_model.rb +26 -3
- data/lib/volt/models/model.rb +18 -19
- data/lib/volt/models/persistors/array_store.rb +2 -10
- data/lib/volt/models/root_models/store_root.rb +17 -4
- data/lib/volt/models/validations/validations.rb +1 -1
- data/lib/volt/models/validators/unique_validator.rb +1 -1
- data/lib/volt/models.rb +1 -1
- data/lib/volt/page/bindings/attribute_binding.rb +5 -4
- data/lib/volt/page/bindings/base_binding.rb +17 -0
- data/lib/volt/page/bindings/content_binding.rb +7 -5
- data/lib/volt/page/bindings/each_binding.rb +62 -51
- data/lib/volt/page/bindings/event_binding.rb +14 -0
- data/lib/volt/page/bindings/view_binding.rb +1 -1
- data/lib/volt/reactive/computation.rb +22 -13
- data/lib/volt/reactive/dependency.rb +0 -24
- data/lib/volt/router/routes.rb +35 -0
- data/lib/volt/server/forking_server.rb +26 -3
- data/lib/volt/server/message_bus/peer_to_peer/peer_connection.rb +1 -1
- data/lib/volt/server/message_bus/peer_to_peer/server_tracker.rb +1 -1
- data/lib/volt/server/message_bus/peer_to_peer.rb +28 -21
- data/lib/volt/server/middleware/default_middleware_stack.rb +67 -0
- data/lib/volt/server/middleware/middleware_stack.rb +58 -0
- data/lib/volt/server/rack/http_request.rb +1 -1
- data/lib/volt/server/rack/http_resource.rb +7 -0
- data/lib/volt/server/rack/keep_alive.rb +20 -0
- data/lib/volt/server/socket_connection_handler.rb +10 -1
- data/lib/volt/server.rb +6 -76
- data/lib/volt/utils/promise_extensions.rb +5 -1
- data/lib/volt/utils/set_patch.rb +25 -0
- data/lib/volt/utils/timers.rb +12 -0
- data/lib/volt/version.rb +1 -1
- data/lib/volt/volt/app.rb +13 -1
- data/lib/volt/volt/server_setup/app.rb +19 -1
- data/lib/volt/volt/users.rb +11 -22
- data/lib/volt.rb +1 -0
- data/spec/apps/kitchen_sink/Gemfile +1 -1
- data/spec/apps/kitchen_sink/app/main/config/routes.rb +1 -1
- data/spec/apps/kitchen_sink/app/main/controllers/main_controller.rb +22 -0
- data/spec/apps/kitchen_sink/app/main/views/main/bindings.html +10 -0
- data/spec/apps/kitchen_sink/app/main/views/main/store_demo.html +9 -0
- data/spec/controllers/http_controller_spec.rb +27 -0
- data/spec/integration/bindings_spec.rb +29 -0
- data/spec/integration/store_spec.rb +7 -7
- data/spec/models/associations_spec.rb +1 -1
- data/spec/models/model_spec.rb +10 -0
- data/spec/models/permissions_spec.rb +7 -4
- data/spec/reactive/computation_spec.rb +33 -5
- data/spec/router/routes_spec.rb +69 -0
- data/spec/server/middleware/middleware_handler.rb +24 -0
- data/spec/spec_helper.rb +1 -1
- data/spec/tasks/user_tasks_spec.rb +3 -2
- data/templates/project/Gemfile.tt +2 -2
- data/templates/project/config/base/index.html +5 -1
- metadata +10 -5
- data/spec/apps/kitchen_sink/app/main/views/main/store.html +0 -9
- data/templates/project/app/main/models/.empty_directory +0 -0
@@ -117,11 +117,17 @@ describe Volt::Computation do
|
|
117
117
|
promise = Promise.new
|
118
118
|
count = 0
|
119
119
|
|
120
|
-
|
120
|
+
success = lambda do |result|
|
121
121
|
expect(result).to eq('resolved')
|
122
122
|
count += 1
|
123
123
|
end
|
124
124
|
|
125
|
+
failure = lambda do |error|
|
126
|
+
|
127
|
+
end
|
128
|
+
|
129
|
+
-> { promise }.watch_and_resolve!(success, failure)
|
130
|
+
|
125
131
|
expect(count).to eq(0)
|
126
132
|
|
127
133
|
promise.resolve('resolved')
|
@@ -137,9 +143,10 @@ describe Volt::Computation do
|
|
137
143
|
cur_val = promise
|
138
144
|
|
139
145
|
results = []
|
140
|
-
|
146
|
+
success = lambda do |val|
|
141
147
|
results << val
|
142
148
|
end
|
149
|
+
-> { dep.depend ; cur_val }.watch_and_resolve!(success)
|
143
150
|
|
144
151
|
expect(results).to eq([])
|
145
152
|
|
@@ -153,16 +160,18 @@ describe Volt::Computation do
|
|
153
160
|
expect(results).to eq([5])
|
154
161
|
end
|
155
162
|
|
156
|
-
it 'should
|
163
|
+
it 'should call success with nil for an unresolved promise when asked' do
|
157
164
|
dep = Volt::Dependency.new
|
158
165
|
|
159
166
|
cur_val = Promise.new
|
160
167
|
|
161
168
|
results = []
|
162
|
-
|
169
|
+
success = lambda do |val|
|
163
170
|
results << val
|
164
171
|
end
|
165
172
|
|
173
|
+
-> { dep.depend ; cur_val }.watch_and_resolve!(success, nil, true)
|
174
|
+
|
166
175
|
expect(results).to eq([nil])
|
167
176
|
|
168
177
|
cur_val.resolve(5)
|
@@ -176,10 +185,12 @@ describe Volt::Computation do
|
|
176
185
|
cur_val = Promise.new
|
177
186
|
|
178
187
|
results = []
|
179
|
-
|
188
|
+
success = lambda do |val|
|
180
189
|
results << val
|
181
190
|
end
|
182
191
|
|
192
|
+
computation = -> { dep.depend ; cur_val }.watch_and_resolve!(success)
|
193
|
+
|
183
194
|
expect(results).to eq([])
|
184
195
|
|
185
196
|
computation.stop
|
@@ -188,6 +199,23 @@ describe Volt::Computation do
|
|
188
199
|
|
189
200
|
expect(results).to eq([])
|
190
201
|
end
|
202
|
+
|
203
|
+
it 'should call the fail on a failure' do
|
204
|
+
cur_val = Promise.new
|
205
|
+
|
206
|
+
results = []
|
207
|
+
success = lambda {}
|
208
|
+
failure = lambda do |error|
|
209
|
+
results << error
|
210
|
+
end
|
211
|
+
|
212
|
+
computation = -> { cur_val }.watch_and_resolve!(success, failure)
|
213
|
+
|
214
|
+
cur_val.reject('broken')
|
215
|
+
computation.stop
|
216
|
+
|
217
|
+
expect(results).to eq(['broken'])
|
218
|
+
end
|
191
219
|
end
|
192
220
|
|
193
221
|
# Currently Class#class_variable_set/get isn't in opal
|
data/spec/router/routes_spec.rb
CHANGED
@@ -246,4 +246,73 @@ describe Volt::Routes do
|
|
246
246
|
|
247
247
|
params = @routes.url_to_params('/blog/20')
|
248
248
|
end
|
249
|
+
|
250
|
+
it 'should setup RESTful routes' do
|
251
|
+
routes do
|
252
|
+
rest '/api/v1/articles', controller: 'articles'
|
253
|
+
end
|
254
|
+
|
255
|
+
params = @routes.url_to_params(:get, '/api/v1/articles')
|
256
|
+
expect(params).to eq(controller: 'articles', action: 'index')
|
257
|
+
|
258
|
+
params = @routes.url_to_params(:get, '/api/v1/articles/1')
|
259
|
+
expect(params).to eq(controller: 'articles', action: 'show', id: '1')
|
260
|
+
|
261
|
+
params = @routes.url_to_params(:post, '/api/v1/articles')
|
262
|
+
expect(params).to eq(controller: 'articles', action: 'create')
|
263
|
+
|
264
|
+
params = @routes.url_to_params(:put, '/api/v1/articles/1')
|
265
|
+
expect(params).to eq(controller: 'articles', action: 'update', id: '1')
|
266
|
+
|
267
|
+
params = @routes.url_to_params(:delete, '/api/v1/articles/1')
|
268
|
+
expect(params).to eq(controller: 'articles', action: 'destroy', id: '1')
|
269
|
+
end
|
270
|
+
|
271
|
+
it 'should only setup desired RESTful routes' do
|
272
|
+
routes do
|
273
|
+
rest '/api/v1/articles', controller: 'articles', only: [:index, :show]
|
274
|
+
end
|
275
|
+
|
276
|
+
params = @routes.url_to_params(:get, '/api/v1/articles')
|
277
|
+
expect(params).to eq(controller: 'articles', action: 'index')
|
278
|
+
|
279
|
+
params = @routes.url_to_params(:get, '/api/v1/articles/1')
|
280
|
+
expect(params).to eq(controller: 'articles', action: 'show', id: '1')
|
281
|
+
|
282
|
+
expect(@routes.url_to_params(:post, '/api/v1/articles')).to be_nil
|
283
|
+
expect(@routes.url_to_params(:put, '/api/v1/articles/1')).to be_nil
|
284
|
+
expect(@routes.url_to_params(:delete, '/api/v1/articles/1')).to be_nil
|
285
|
+
|
286
|
+
routes do
|
287
|
+
rest '/api/v1/articles', controller: 'articles', only: [:update, :destroy, :create]
|
288
|
+
end
|
289
|
+
|
290
|
+
expect(@routes.url_to_params(:get, '/api/v1/articles')).to be_nil
|
291
|
+
expect(@routes.url_to_params(:get, '/api/v1/articles/1')).to be_nil
|
292
|
+
|
293
|
+
params = @routes.url_to_params(:post, '/api/v1/articles')
|
294
|
+
expect(params).to eq(controller: 'articles', action: 'create')
|
295
|
+
|
296
|
+
params = @routes.url_to_params(:put, '/api/v1/articles/1')
|
297
|
+
expect(params).to eq(controller: 'articles', action: 'update', id: '1')
|
298
|
+
|
299
|
+
params = @routes.url_to_params(:delete, '/api/v1/articles/1')
|
300
|
+
expect(params).to eq(controller: 'articles', action: 'destroy', id: '1')
|
301
|
+
end
|
302
|
+
|
303
|
+
it 'should exclude undesired RESTful routes' do
|
304
|
+
routes do
|
305
|
+
rest '/api/v1/articles', controller: 'articles', except: [:update, :destroy, :create]
|
306
|
+
end
|
307
|
+
|
308
|
+
params = @routes.url_to_params(:get, '/api/v1/articles')
|
309
|
+
expect(params).to eq(controller: 'articles', action: 'index')
|
310
|
+
|
311
|
+
params = @routes.url_to_params(:get, '/api/v1/articles/1')
|
312
|
+
expect(params).to eq(controller: 'articles', action: 'show', id: '1')
|
313
|
+
|
314
|
+
expect(@routes.url_to_params(:post, '/api/v1/articles')).to be_nil
|
315
|
+
expect(@routes.url_to_params(:put, '/api/v1/articles/1')).to be_nil
|
316
|
+
expect(@routes.url_to_params(:delete, '/api/v1/articles/1')).to be_nil
|
317
|
+
end
|
249
318
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
unless RUBY_PLATFORM == 'opal'
|
4
|
+
describe Volt::MiddlewareStack do
|
5
|
+
before do
|
6
|
+
@stack = Volt::MiddlewareStack.new
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'should set_app' do
|
10
|
+
app = double('rack app')
|
11
|
+
@stack.set_app(app)
|
12
|
+
expect(@stack.instance_variable_get('@app')).to eq(app)
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should insert a middleware at the end of the stack when calling use' do
|
16
|
+
middleware1 = double('middleware1')
|
17
|
+
@stack.use(middleware1, 'arg1')
|
18
|
+
|
19
|
+
expect(@stack.middlewares).to eq([
|
20
|
+
[[middleware1, 'arg1'], nil]
|
21
|
+
])
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -2,7 +2,8 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
if RUBY_PLATFORM != 'opal'
|
4
4
|
describe UserTasks do
|
5
|
-
let(:
|
5
|
+
let(:user_promise) { double('UserPromise', then: true) }
|
6
|
+
let(:fake_response) { double('FakeResponse', first: user_promise) }
|
6
7
|
|
7
8
|
let(:fake_users_collection) do
|
8
9
|
double('FakeUsersCollection', where: fake_response)
|
@@ -15,7 +16,7 @@ if RUBY_PLATFORM != 'opal'
|
|
15
16
|
before do
|
16
17
|
allow($page).to receive(:store).and_return fake_store
|
17
18
|
allow(User).to receive(:login_field).and_return 'user'
|
18
|
-
allow(
|
19
|
+
allow(user_promise).to receive(:then).and_yield(user)
|
19
20
|
end
|
20
21
|
|
21
22
|
subject { UserTasks.new(Volt.current_app) }
|
@@ -3,7 +3,7 @@ source 'https://rubygems.org'
|
|
3
3
|
gem 'volt', '<%= config[:version] %>'
|
4
4
|
|
5
5
|
# volt uses mongo as the default data store.
|
6
|
-
gem 'volt-mongo', '~> 0.0
|
6
|
+
gem 'volt-mongo', '~> 0.1.0'
|
7
7
|
|
8
8
|
# The following gem's are optional for themeing
|
9
9
|
# Twitter bootstrap
|
@@ -13,7 +13,7 @@ gem 'volt-bootstrap', '~> 0.0.10'
|
|
13
13
|
gem 'volt-bootstrap_jumbotron_theme', '~> 0.1.0'
|
14
14
|
|
15
15
|
# User templates for login, signup, and logout menu.
|
16
|
-
gem 'volt-user_templates', '~> 0.
|
16
|
+
gem 'volt-user_templates', '~> 0.4.0'
|
17
17
|
|
18
18
|
# Add ability to send e-mail from apps.
|
19
19
|
gem 'volt-mailer', '~> 0.1.0'
|
@@ -1,8 +1,12 @@
|
|
1
|
+
<%# IMPORTANT: Please read before changing! %>
|
2
|
+
<%# This file is rendered on the server using ERB, so it does NOT use Volt's %>
|
3
|
+
<%# normal template system. You can add to it, but keep in mind the template %>
|
4
|
+
<%# language difference. This file handles auto-loading all JS/Opal and CSS. %>
|
5
|
+
|
1
6
|
<!DOCTYPE html>
|
2
7
|
<html>
|
3
8
|
<head>
|
4
9
|
<meta charset="UTF-8" />
|
5
|
-
<%# This file is rendered on the server and does not uses erb instead of Volt's normal template system. You can add to it, but keep in mind the template language difference. It handles auto-loading all JS/Opal and Css %>
|
6
10
|
<% javascript_files.each do |javascript_file| %>
|
7
11
|
<script src="<%= javascript_file %>"></script>
|
8
12
|
<% end %>
|
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.3.
|
4
|
+
version: 0.9.3.pre4
|
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-05
|
11
|
+
date: 2015-06-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -543,6 +543,8 @@ files:
|
|
543
543
|
- lib/volt/server/message_bus/peer_to_peer/server_tracker.rb
|
544
544
|
- lib/volt/server/message_bus/peer_to_peer/socket_with_timeout.rb
|
545
545
|
- lib/volt/server/message_bus/redis.rb
|
546
|
+
- lib/volt/server/middleware/default_middleware_stack.rb
|
547
|
+
- lib/volt/server/middleware/middleware_stack.rb
|
546
548
|
- lib/volt/server/rack/asset_files.rb
|
547
549
|
- lib/volt/server/rack/component_code.rb
|
548
550
|
- lib/volt/server/rack/component_paths.rb
|
@@ -551,6 +553,7 @@ files:
|
|
551
553
|
- lib/volt/server/rack/http_response_header.rb
|
552
554
|
- lib/volt/server/rack/http_response_renderer.rb
|
553
555
|
- lib/volt/server/rack/index_files.rb
|
556
|
+
- lib/volt/server/rack/keep_alive.rb
|
554
557
|
- lib/volt/server/rack/opal_files.rb
|
555
558
|
- lib/volt/server/rack/quiet_common_logger.rb
|
556
559
|
- lib/volt/server/rack/source_map_server.rb
|
@@ -579,6 +582,7 @@ files:
|
|
579
582
|
- lib/volt/utils/promise.rb
|
580
583
|
- lib/volt/utils/promise_extensions.rb
|
581
584
|
- lib/volt/utils/read_write_lock.rb
|
585
|
+
- lib/volt/utils/set_patch.rb
|
582
586
|
- lib/volt/utils/tilt_patch.rb
|
583
587
|
- lib/volt/utils/timers.rb
|
584
588
|
- lib/volt/utils/volt_user_error.rb
|
@@ -617,7 +621,7 @@ files:
|
|
617
621
|
- spec/apps/kitchen_sink/app/main/views/main/main.html
|
618
622
|
- spec/apps/kitchen_sink/app/main/views/main/missing.html
|
619
623
|
- spec/apps/kitchen_sink/app/main/views/main/require_test.html
|
620
|
-
- spec/apps/kitchen_sink/app/main/views/main/
|
624
|
+
- spec/apps/kitchen_sink/app/main/views/main/store_demo.html
|
621
625
|
- spec/apps/kitchen_sink/app/main/views/main/yield.html
|
622
626
|
- spec/apps/kitchen_sink/app/main/views/todos/index.html
|
623
627
|
- spec/apps/kitchen_sink/app/main/views/upload/index.html
|
@@ -699,6 +703,7 @@ files:
|
|
699
703
|
- spec/server/message_bus/peer_to_peer/peer_server_spec.rb
|
700
704
|
- spec/server/message_bus/peer_to_peer/socket_with_timeout_spec.rb
|
701
705
|
- spec/server/message_bus/peer_to_peer_spec.rb
|
706
|
+
- spec/server/middleware/middleware_handler.rb
|
702
707
|
- spec/server/rack/asset_files_spec.rb
|
703
708
|
- spec/server/rack/component_paths_spec.rb
|
704
709
|
- spec/server/rack/http_request_spec.rb
|
@@ -785,7 +790,6 @@ files:
|
|
785
790
|
- templates/project/app/main/config/routes.rb
|
786
791
|
- templates/project/app/main/controllers/main_controller.rb
|
787
792
|
- templates/project/app/main/lib/.empty_directory
|
788
|
-
- templates/project/app/main/models/.empty_directory
|
789
793
|
- templates/project/app/main/models/user.rb
|
790
794
|
- templates/project/app/main/tasks/.empty_directory
|
791
795
|
- templates/project/app/main/views/main/about.html
|
@@ -860,7 +864,7 @@ test_files:
|
|
860
864
|
- spec/apps/kitchen_sink/app/main/views/main/main.html
|
861
865
|
- spec/apps/kitchen_sink/app/main/views/main/missing.html
|
862
866
|
- spec/apps/kitchen_sink/app/main/views/main/require_test.html
|
863
|
-
- spec/apps/kitchen_sink/app/main/views/main/
|
867
|
+
- spec/apps/kitchen_sink/app/main/views/main/store_demo.html
|
864
868
|
- spec/apps/kitchen_sink/app/main/views/main/yield.html
|
865
869
|
- spec/apps/kitchen_sink/app/main/views/todos/index.html
|
866
870
|
- spec/apps/kitchen_sink/app/main/views/upload/index.html
|
@@ -942,6 +946,7 @@ test_files:
|
|
942
946
|
- spec/server/message_bus/peer_to_peer/peer_server_spec.rb
|
943
947
|
- spec/server/message_bus/peer_to_peer/socket_with_timeout_spec.rb
|
944
948
|
- spec/server/message_bus/peer_to_peer_spec.rb
|
949
|
+
- spec/server/middleware/middleware_handler.rb
|
945
950
|
- spec/server/rack/asset_files_spec.rb
|
946
951
|
- spec/server/rack/component_paths_spec.rb
|
947
952
|
- spec/server/rack/http_request_spec.rb
|
File without changes
|