volt 0.9.1.pre2 → 0.9.1.pre3

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: ad2f798ba0d81a985f87b8ff96e53b84797644c8
4
- data.tar.gz: 9b71d94cfc22e7ac63e51dfa0375d33759f5ecfd
3
+ metadata.gz: dc7e6af465488d4433ccb709514b3f805ad16cc7
4
+ data.tar.gz: 25cbe6bf32e904f35db51bd8d2b5b4822a1d81cd
5
5
  SHA512:
6
- metadata.gz: 0ac6eadbc636ff75bf155cb6babf498499c70c81526b758a6028d8b2d315262e190bf7ddcd27d524c5bfa2f4b0d1205d7cfb85413436fa94862f40a33c7bdc99
7
- data.tar.gz: d8cebc99bc26b65ecd9df5f5826f8d2d4e696f00e859f294db53510bbc4936436866f1a0b9d12f5f62dabf6adaa8a1da43691a80f54f18b7a96bf632b678e977
6
+ metadata.gz: f21a61b49bf832d0f234271dcaa247401c80e43d4754fed3fcc49b17cfb61bb68f5aa1283379256449a0f1c881b1f80a59f1709387acecb172443f45b16c9220
7
+ data.tar.gz: c51891e601da7711ebc8324fcfa5d89f2d5b5524017b09ceeab9fa20a44a7cec36a9b98af3e9d4bad380e6140c8e1b6cbd0bd7588ea91fbc002d84d86bfdab6d
data/CHANGELOG.md CHANGED
@@ -2,11 +2,13 @@
2
2
 
3
3
  ## 0.9.1
4
4
  ### Changed
5
+ - All code in ```app``` is now automatically reloaded when any files change. This is done through a "preforking" server. Before your apps code is loaded (and after Volt's is), the server forks a child process to handle the request (in dev and test mode).
5
6
  - Corrected the name of StringTemplateRender to StringTemplateRenderer
6
7
  - Volt now uses faye-websocket for socket connections. This means we can run on any rack-hijack server supported by faye-websocket. Currently Volt is tested with thin and puma. (Note: Thin will probably have better performance since it is evented, which means it doesn't need a thread per connection) More servers coming soon.
7
8
  - fixed issue with the unique validation.
8
9
  - made it so <:SectionName> can be accessed by <:section_name /> tag
9
10
  - fixed issue with if bindings not resolving some promises.
11
+ - fixed issue with require's in controllers.
10
12
 
11
13
  ## 0.9.0
12
14
  ### Added
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.1.pre2
1
+ 0.9.1.pre3
@@ -16,6 +16,7 @@ module Volt
16
16
  require 'opal'
17
17
  require 'rack'
18
18
  require 'volt'
19
+ require 'volt/volt/core'
19
20
  require 'volt/boot'
20
21
 
21
22
 
@@ -71,7 +72,6 @@ module Volt
71
72
  path = "#{@root_path}/public/assets/#{logical_path}"
72
73
 
73
74
  begin
74
- puts "LP: #{logical_path.inspect}"
75
75
  content = @opal_files.environment[logical_path].to_s
76
76
  write_file(path, content)
77
77
  rescue Sprockets::FileNotFound, SyntaxError => e
@@ -28,7 +28,13 @@ module Volt
28
28
 
29
29
  def connect!
30
30
  %x{
31
- this.socket = new WebSocket('ws://' + document.location.host + '/socket');
31
+ if (document.location.protocol == 'https:') {
32
+ var wsProto = 'wss';
33
+ } else {
34
+ var wsProto = 'ws';
35
+ }
36
+
37
+ this.socket = new WebSocket(wsProto + '://' + document.location.host + '/socket');
32
38
 
33
39
  this.socket.onopen = function () {
34
40
  self.$opened();
@@ -142,8 +142,18 @@ module Volt
142
142
  end
143
143
  end
144
144
 
145
- def reload
146
- Volt.logger.log_with_color('file changed, sending reload', :light_blue)
145
+ def reload(changed_files)
146
+ # only reload the server code if a non-view file was changed
147
+ server_code_changed = changed_files.any? {|path| File.extname(path) == '.rb' }
148
+
149
+ msg = 'file changed, reloading'
150
+ if server_code_changed
151
+ msg << ' server and'
152
+ end
153
+ msg << ' client...'
154
+
155
+ Volt.logger.log_with_color(msg, :light_blue)
156
+
147
157
  begin
148
158
  SocketConnectionHandler.send_message_all(nil, 'reload')
149
159
  rescue => e
@@ -151,9 +161,11 @@ module Volt
151
161
  Volt.logger.error(e)
152
162
  end
153
163
 
154
- @child_lock.with_write_lock do
155
- stop_child
156
- start_child
164
+ if server_code_changed
165
+ @child_lock.with_write_lock do
166
+ stop_child
167
+ start_child
168
+ end
157
169
  end
158
170
  end
159
171
 
@@ -162,7 +174,7 @@ module Volt
162
174
  @listener = Listen.to("#{@server.app_path}/") do |modified, added, removed|
163
175
  Thread.new do
164
176
  # Run the reload in a new thread
165
- reload
177
+ reload(modified + added + removed)
166
178
  end
167
179
  end
168
180
  @listener.start
data/lib/volt/server.rb CHANGED
@@ -76,7 +76,14 @@ module Volt
76
76
  # Handle websocket connections
77
77
  app.use WebsocketHandler
78
78
 
79
- if Volt.env.production? || Volt.env.test?
79
+ can_fork = Process.respond_to?(:fork)
80
+
81
+ unless can_fork
82
+ Volt.logger.warn('Code reloading in Volt currently depends on `fork`. Your environment does not support `fork`. We\'re working on adding more reloading strategies. For now though you\'ll need to restart the server manually on changes, which sucks. Feel free to complain to the devs, we really let you down here. :-)')
83
+ end
84
+
85
+ # Only run ForkingServer if fork is supported in this env.
86
+ if !can_fork || Volt.env.production? || Volt.env.test?
80
87
  # In production/test, we boot the app and run the server
81
88
  #
82
89
  # Sometimes the app is already booted, so we can skip if it is
data/lib/volt/volt/app.rb CHANGED
@@ -37,7 +37,7 @@ module Volt
37
37
  Dir["#{app_folder}/*/controllers/server/*.rb"].each do |ruby_file|
38
38
  #path = ruby_file.gsub(/^#{app_folder}\//, '')[0..-4]
39
39
  #require(path)
40
- load ruby_file
40
+ require(ruby_file)
41
41
  end
42
42
  end
43
43
  end
@@ -10,6 +10,7 @@ client '/first_last', action: 'first_last'
10
10
  client '/todos', controller: 'todos'
11
11
  client '/html_safe', action: 'html_safe'
12
12
  client '/missing', action: 'missing'
13
+ client '/require_test', action: 'require_test'
13
14
 
14
15
  # Signup/login routes
15
16
  client '/signup', component: 'user_templates', controller: 'signup'
@@ -1,3 +1,6 @@
1
+ # Require date for require test
2
+ require 'date'
3
+
1
4
  module Main
2
5
  class MainController < Volt::ModelController
3
6
  model :page
@@ -0,0 +1,7 @@
1
+ <:Title>
2
+ Require Test
3
+
4
+ <:Body>
5
+ <h1>Require Test</h1>
6
+
7
+ <p>Date Class: {{ Date.respond_to?(:today).inspect }}</p>
@@ -0,0 +1,9 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'client require', type: :feature, sauce: true do
4
+ it 'should require code in controllers' do
5
+ visit '/require_test'
6
+
7
+ expect(page).to have_content('Date Class: true')
8
+ end
9
+ end
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+
3
+ unless RUBY_PLATFORM == 'opal'
4
+ class Fridge < Volt::Model
5
+ validate :name, unique: true
6
+ end
7
+
8
+
9
+ describe 'unique spec' do
10
+ it 'should reject save if there are records with existing attributes already' do
11
+ store._fridges << { name: 'swift' }
12
+ fridge = store._fridges.buffer name: 'swift'
13
+ fridge.save!.then do
14
+ expect(false).to be_true
15
+ end.fail do
16
+ expect(true).to be_true
17
+ end
18
+ end
19
+
20
+ it 'should not increase count of the total records in the store' do
21
+ store._fridges << { name: 'swift' }
22
+ store._fridges << { name: 'swift' }
23
+ expect(store._fridges.count).to eq(1)
24
+ end
25
+ end
26
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: volt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1.pre2
4
+ version: 0.9.1.pre3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Stout
@@ -701,6 +701,7 @@ files:
701
701
  - spec/apps/kitchen_sink/app/main/views/main/index.html
702
702
  - spec/apps/kitchen_sink/app/main/views/main/main.html
703
703
  - spec/apps/kitchen_sink/app/main/views/main/missing.html
704
+ - spec/apps/kitchen_sink/app/main/views/main/require_test.html
704
705
  - spec/apps/kitchen_sink/app/main/views/main/store.html
705
706
  - spec/apps/kitchen_sink/app/main/views/main/yield.html
706
707
  - spec/apps/kitchen_sink/app/main/views/todos/index.html
@@ -723,6 +724,7 @@ files:
723
724
  - spec/extra_core/string_transformations_spec.rb
724
725
  - spec/extra_core/symbol_spec.rb
725
726
  - spec/integration/bindings_spec.rb
727
+ - spec/integration/client_require_spec.rb
726
728
  - spec/integration/cookies_spec.rb
727
729
  - spec/integration/first_last_spec.rb
728
730
  - spec/integration/flash_spec.rb
@@ -751,6 +753,7 @@ files:
751
753
  - spec/models/validators/length_validator_spec.rb
752
754
  - spec/models/validators/phone_number_validator_spec.rb
753
755
  - spec/models/validators/shared_examples_for_validators.rb
756
+ - spec/models/validators/unique_validator_spec.rb
754
757
  - spec/page/bindings/content_binding_spec.rb
755
758
  - spec/page/bindings/template_binding/view_lookup_for_path_spec.rb
756
759
  - spec/page/bindings/template_binding_spec.rb
@@ -910,6 +913,7 @@ test_files:
910
913
  - spec/apps/kitchen_sink/app/main/views/main/index.html
911
914
  - spec/apps/kitchen_sink/app/main/views/main/main.html
912
915
  - spec/apps/kitchen_sink/app/main/views/main/missing.html
916
+ - spec/apps/kitchen_sink/app/main/views/main/require_test.html
913
917
  - spec/apps/kitchen_sink/app/main/views/main/store.html
914
918
  - spec/apps/kitchen_sink/app/main/views/main/yield.html
915
919
  - spec/apps/kitchen_sink/app/main/views/todos/index.html
@@ -932,6 +936,7 @@ test_files:
932
936
  - spec/extra_core/string_transformations_spec.rb
933
937
  - spec/extra_core/symbol_spec.rb
934
938
  - spec/integration/bindings_spec.rb
939
+ - spec/integration/client_require_spec.rb
935
940
  - spec/integration/cookies_spec.rb
936
941
  - spec/integration/first_last_spec.rb
937
942
  - spec/integration/flash_spec.rb
@@ -960,6 +965,7 @@ test_files:
960
965
  - spec/models/validators/length_validator_spec.rb
961
966
  - spec/models/validators/phone_number_validator_spec.rb
962
967
  - spec/models/validators/shared_examples_for_validators.rb
968
+ - spec/models/validators/unique_validator_spec.rb
963
969
  - spec/page/bindings/content_binding_spec.rb
964
970
  - spec/page/bindings/template_binding/view_lookup_for_path_spec.rb
965
971
  - spec/page/bindings/template_binding_spec.rb