volt 0.9.6.pre1 → 0.9.6.pre2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 29fb4233ac14f8c7e64e2989d8b35afef2ad5c46
4
- data.tar.gz: 88a4befaffac7d6f0eeba74dcc8c8ca5d4f792ee
3
+ metadata.gz: 16b909f645dc9943c62dcd512df36371ac4c1dfc
4
+ data.tar.gz: 3b1bc0f0bdeef3eef63f9f7fbcbf47042a9f3fbe
5
5
  SHA512:
6
- metadata.gz: 3bd5f4136741543d23af692202144ae62b6f2b4ca239149da6449901b1ef98d8fe4a9cb5b17f747c09cc9918d29ff73a176b6a72ab7e4e7329ee317273100b75
7
- data.tar.gz: 608bfcaa76b62dc7e0a7fa085ade630b7dafb466568d6ac046a4f3a3fe205f04fabec87a33f98b0b987d97357f22ffefdbb468118460e6b609eb44e3afc51943
6
+ metadata.gz: af36ac78914b63e4c3a1c9161a64ec36e85f317320540461bb5008852261a9c0f66a2016f9130d4578122fd4eab8f1bba62eff2e8c48746d9451d87bab66c09e
7
+ data.tar.gz: 909e57f674271f32315f0f987cb28035703ed949bd704fe601c7ad547a287b9262a10f45525964796f8c92d557102cb3e232f44a82761f7a6da43acf854b12f6
data/CHANGELOG.md CHANGED
@@ -7,6 +7,7 @@
7
7
  ### Changed
8
8
  - Finally tracked down an illusive memory leak.
9
9
  - Computations now raise an error on their inital run, then log errors (via Volt.logger.error(..)) when running again (since they update on next tick)
10
+ - fixed template caching issue
10
11
 
11
12
  ## 0.9.5
12
13
  ### Breaking Changes
@@ -24,7 +24,10 @@ module Volt
24
24
  return validate!.then do
25
25
  # Buffers are allowed to be in an invalid state
26
26
  unless buffer?
27
- # First check that all local validations pass
27
+ # First check that all local validations pass. Any time any
28
+ # validations fail, the model is in an invalid state and won't
29
+ # persist. However, we want to be able to move the model
30
+ # towards a valid state one change at a time.
28
31
  if error_in_changed_attributes?
29
32
  # Some errors are present, revert changes
30
33
  revert_changes!
@@ -114,7 +114,10 @@ module Volt
114
114
  end.fail do |errors|
115
115
  save_promises = @save_promises
116
116
  @save_promises = nil
117
- save_promises.each { |promise| promise.reject(errors) }
117
+
118
+ # Rewrap in Volt::Errors
119
+ errors = Volt::Errors.new(errors)
120
+ save_promises.each { |promise| promise.reject(errors) }
118
121
 
119
122
  # Mark that we failed to save
120
123
  @model.change_state_to(:saved_state, :save_failed)
@@ -41,9 +41,17 @@ module Volt
41
41
  # Re-raise if we are in the initial run
42
42
  raise
43
43
  else
44
- msg = "Exception During Compute: " + e.inspect
45
- msg += "\n" + e.backtrace.join("\n") if e.respond_to?(:backtrace)
46
- Volt.logger.error(msg)
44
+ # Sometimes we get nil as the exception, not sure if thats an opal
45
+ # issue or what.
46
+ if e
47
+ msg = "Exception During Compute: " + e.inspect
48
+ msg += "\n" + e.backtrace.join("\n") if e.respond_to?(:backtrace)
49
+ Volt.logger.error(msg)
50
+
51
+ if RUBY_PLATFORM == 'opal'
52
+ `console.log(e);`
53
+ end
54
+ end
47
55
  end
48
56
  ensure
49
57
  @computing = false
@@ -3,13 +3,13 @@ require 'opal/sprockets/processor'
3
3
  require 'sprockets'
4
4
  require 'tilt'
5
5
  require 'opal/sprockets/processor'
6
+ require 'sprockets/uri_utils'
6
7
 
7
8
  module Volt
8
9
 
9
10
 
10
11
 
11
12
  class ViewProcessor < ::Opal::TiltTemplate
12
-
13
13
  def initialize(client)
14
14
  @client = client
15
15
  end
@@ -49,6 +49,10 @@ module Volt
49
49
  # puts input[:data].inspect
50
50
  # Remove all semicolons from source
51
51
  # input[:content_type] = 'application/javascript'
52
+
53
+ # Track the dependency
54
+ context.metadata[:dependencies] << Sprockets::URIUtils.build_file_digest_uri(input[:filename])
55
+
52
56
  compile(filename, input[:data], context)
53
57
  end
54
58
 
@@ -81,10 +85,9 @@ module Volt
81
85
 
82
86
  def self.setup(sprockets=$volt_app.sprockets)
83
87
  exts = ComponentTemplates::Preprocessors.extensions.map{ |ext| ".#{ext}" }
84
-
88
+
85
89
  sprockets.register_mime_type 'application/vtemplate', extensions: exts
86
90
  sprockets.register_transformer 'application/vtemplate', 'application/javascript', Volt::ViewProcessor.new(true)
87
91
  end
88
92
  end
89
93
  end
90
-
@@ -151,11 +151,28 @@ module Volt
151
151
 
152
152
  finish.call
153
153
  end.fail do |error|
154
- finish.call(error)
155
- # Convert the error into a string so it can be serialized.
156
- error_str = "#{error.class.to_s}: #{error.to_s}"
154
+ begin
155
+ finish.call(error)
156
+
157
+ begin
158
+ # Try to send, handle error if we can't convert the result to EJSON
159
+ reply = EJSON.stringify(['response', callback_id, nil, error, cookies])
160
+
161
+ # use send_string_message, since we stringify here, not on the other
162
+ # side of Drb.
163
+ channel.send_string_message(reply)
164
+ rescue EJSON::NonEjsonType => e
165
+ # Convert the error into a string so it can be serialized to
166
+ # something.
167
+ error = "#{error.class.to_s}: #{error.to_s}"
168
+ channel.send_message('response', callback_id, nil, error, cookies)
169
+ end
157
170
 
158
- channel.send_message('response', callback_id, nil, error_str, cookies)
171
+ rescue => e
172
+ Volt.logger.error "Error in fail dispatch: #{e.inspect}"
173
+ Volt.logger.error(e.backtrace.join("\n")) if e.respond_to?(:backtrace)
174
+ raise
175
+ end
159
176
  end
160
177
 
161
178
  end
data/lib/volt/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Volt
2
2
  module Version
3
- STRING = '0.9.6.pre1'
3
+ STRING = '0.9.6.pre2'
4
4
  end
5
5
  end
@@ -36,4 +36,4 @@ module Volt
36
36
  @templates
37
37
  end
38
38
  end
39
- end
39
+ end
@@ -16,7 +16,7 @@ gem 'volt-bootstrap_jumbotron_theme', '~> 0.1.0'
16
16
  gem 'volt-user_templates', '~> 0.4.0'
17
17
 
18
18
  # Add ability to send e-mail from apps.
19
- gem 'volt-mailer', '~> 0.1.0'
19
+ gem 'volt-mailer', '~> 0.1.1'
20
20
 
21
21
  gem 'volt-fields'
22
22
 
@@ -19,6 +19,8 @@ client '/callbacks', action: 'callbacks'
19
19
  # Events
20
20
  client '/events', component: 'main', controller: 'events', action: 'index'
21
21
 
22
+ client '/save', component: 'main', controller: 'save', action: 'index'
23
+
22
24
  # Signup/login routes
23
25
  client '/signup', component: 'user_templates', controller: 'signup'
24
26
  client '/login', component: 'user_templates', controller: 'login'
@@ -0,0 +1,9 @@
1
+ module Main
2
+ class SaveController < Volt::ModelController
3
+ def add_post
4
+ store.posts.create(page._new_post.to_h).fail do |err|
5
+ flash._notices << err.inspect
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,5 @@
1
+ class Post < Volt::Model
2
+ field :title, String
3
+
4
+ validate :title, length: 5
5
+ end
@@ -0,0 +1,10 @@
1
+ <:Title>
2
+ Save
3
+
4
+ <:Body>
5
+ <h1>Save</h1>
6
+
7
+ <form e-submit="add_post">
8
+ <input id="post_title" value="{{ page._new_post!._title }}" />
9
+ <button>Save</button>
10
+ </form>
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'saving', type: :feature, sauce: true do
4
+ it 'should return an error as an instance of Volt::Error' do
5
+ visit '/save'
6
+
7
+ fill_in 'post_title', with: 'ok'
8
+
9
+ click_button 'Save'
10
+
11
+ expect(page).to have_content('#<Volt::Errors {"title"=>["must be at least 5 characters"]}>')
12
+ end
13
+ end
@@ -43,7 +43,7 @@ if RUBY_PLATFORM != 'opal'
43
43
  it 'should not allow eval' do
44
44
  channel = double('channel')
45
45
 
46
- expect(channel).to receive(:send_message).with('response', 0, nil, "RuntimeError: unsafe method: eval", nil)
46
+ expect(channel).to receive(:send_message).with('response', 0, nil, 'RuntimeError: unsafe method: eval', nil)
47
47
 
48
48
  dispatcher.dispatch(channel, [0, 'TestTask', :eval, '5 + 10'])
49
49
  end
@@ -51,7 +51,12 @@ if RUBY_PLATFORM != 'opal'
51
51
  it 'should not allow instance_eval' do
52
52
  channel = double('channel')
53
53
 
54
- expect(channel).to receive(:send_message).with('response', 0, nil, 'RuntimeError: unsafe method: instance_eval', nil)
54
+
55
+ first = true
56
+ expect(channel).to receive(:send_message).with("response", 0, nil, 'RuntimeError: unsafe method: instance_eval', nil)
57
+
58
+
59
+ # .with('response', 0, nil, /RuntimeError: unsafe method: instance_eval/, nil)
55
60
 
56
61
  dispatcher.dispatch(channel, [0, 'TestTask', :instance_eval, '5 + 10'])
57
62
  end
@@ -16,7 +16,7 @@ gem 'volt-bootstrap_jumbotron_theme', '~> 0.1.0'
16
16
  gem 'volt-user_templates', '~> 0.4.0'
17
17
 
18
18
  # Add ability to send e-mail from apps.
19
- gem 'volt-mailer', '~> 0.1.0'
19
+ gem 'volt-mailer', '~> 0.1.1'
20
20
 
21
21
  # Use rbnacl for message bus encrpytion
22
22
  # (optional, if you don't need encryption, disable in app.rb and remove)
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.6.pre1
4
+ version: 0.9.6.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-09-29 00:00:00.000000000 Z
11
+ date: 2015-10-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -638,10 +638,12 @@ files:
638
638
  - spec/apps/kitchen_sink/app/main/config/routes.rb
639
639
  - spec/apps/kitchen_sink/app/main/controllers/events_controller.rb
640
640
  - spec/apps/kitchen_sink/app/main/controllers/main_controller.rb
641
+ - spec/apps/kitchen_sink/app/main/controllers/save_controller.rb
641
642
  - spec/apps/kitchen_sink/app/main/controllers/server/simple_http_controller.rb
642
643
  - spec/apps/kitchen_sink/app/main/controllers/todos_controller.rb
643
644
  - spec/apps/kitchen_sink/app/main/controllers/upload_controller.rb
644
645
  - spec/apps/kitchen_sink/app/main/controllers/yield_component_controller.rb
646
+ - spec/apps/kitchen_sink/app/main/models/post.rb
645
647
  - spec/apps/kitchen_sink/app/main/models/user.rb
646
648
  - spec/apps/kitchen_sink/app/main/tasks/login_tasks.rb
647
649
  - spec/apps/kitchen_sink/app/main/views/events/index.html
@@ -661,6 +663,7 @@ files:
661
663
  - spec/apps/kitchen_sink/app/main/views/main/require_test.html
662
664
  - spec/apps/kitchen_sink/app/main/views/main/store_demo.html
663
665
  - spec/apps/kitchen_sink/app/main/views/main/yield.html
666
+ - spec/apps/kitchen_sink/app/main/views/save/index.html
664
667
  - spec/apps/kitchen_sink/app/main/views/todos/index.html
665
668
  - spec/apps/kitchen_sink/app/main/views/upload/index.html
666
669
  - spec/apps/kitchen_sink/app/main/views/yield_component/index.html
@@ -692,6 +695,7 @@ files:
692
695
  - spec/integration/list_spec.rb
693
696
  - spec/integration/missing_spec.rb
694
697
  - spec/integration/raw_html_binding.rb
698
+ - spec/integration/save_spec.rb
695
699
  - spec/integration/store_spec.rb
696
700
  - spec/integration/templates_spec.rb
697
701
  - spec/integration/todos_spec.rb
@@ -913,10 +917,12 @@ test_files:
913
917
  - spec/apps/kitchen_sink/app/main/config/routes.rb
914
918
  - spec/apps/kitchen_sink/app/main/controllers/events_controller.rb
915
919
  - spec/apps/kitchen_sink/app/main/controllers/main_controller.rb
920
+ - spec/apps/kitchen_sink/app/main/controllers/save_controller.rb
916
921
  - spec/apps/kitchen_sink/app/main/controllers/server/simple_http_controller.rb
917
922
  - spec/apps/kitchen_sink/app/main/controllers/todos_controller.rb
918
923
  - spec/apps/kitchen_sink/app/main/controllers/upload_controller.rb
919
924
  - spec/apps/kitchen_sink/app/main/controllers/yield_component_controller.rb
925
+ - spec/apps/kitchen_sink/app/main/models/post.rb
920
926
  - spec/apps/kitchen_sink/app/main/models/user.rb
921
927
  - spec/apps/kitchen_sink/app/main/tasks/login_tasks.rb
922
928
  - spec/apps/kitchen_sink/app/main/views/events/index.html
@@ -936,6 +942,7 @@ test_files:
936
942
  - spec/apps/kitchen_sink/app/main/views/main/require_test.html
937
943
  - spec/apps/kitchen_sink/app/main/views/main/store_demo.html
938
944
  - spec/apps/kitchen_sink/app/main/views/main/yield.html
945
+ - spec/apps/kitchen_sink/app/main/views/save/index.html
939
946
  - spec/apps/kitchen_sink/app/main/views/todos/index.html
940
947
  - spec/apps/kitchen_sink/app/main/views/upload/index.html
941
948
  - spec/apps/kitchen_sink/app/main/views/yield_component/index.html
@@ -967,6 +974,7 @@ test_files:
967
974
  - spec/integration/list_spec.rb
968
975
  - spec/integration/missing_spec.rb
969
976
  - spec/integration/raw_html_binding.rb
977
+ - spec/integration/save_spec.rb
970
978
  - spec/integration/store_spec.rb
971
979
  - spec/integration/templates_spec.rb
972
980
  - spec/integration/todos_spec.rb