boojs 0.0.30 → 0.0.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8afbb0e166580c67fdc4952b918827224e90a09e
4
- data.tar.gz: 0e358c78333c5630542df9a918200f6ab188be6a
3
+ metadata.gz: 96ee4c56f3d5b80a75b2d084e1c56039dc834e5f
4
+ data.tar.gz: e044ad6d195d8565faeed8838fd2c8d2bb83a9a4
5
5
  SHA512:
6
- metadata.gz: 5899ff5185e76d0a1130172f2b0453994faa4c2201bdaf46ed9798c60bf9c7cf713ffa0fdf668715d91d1d4262842d053f1ba1dd936a03a6202c683e39c17e20
7
- data.tar.gz: e18edf2f45f15c15d079894c0598e290c4f376827432b855972487bc2d76300b4722cc9ceab16e2c6c273fee651300278923e4bb3caf30c6c2111fdc1d284a69
6
+ metadata.gz: 16d8523cbe1210b08f194ebee09fc74be614163fced0f057e5cabfe650ea377ec012752e7cd7659ae9ef122d07488b2ad9671a4a9a277a58ef4c8e02351bf03f
7
+ data.tar.gz: 618c00d39140585d135f05e39745fe43208c48f95dceff18a6a58855dd5aeb32ed993bd56f2cf78b5c5ae0f2a57eb3808617c507d73dbf8563e320a479cb8e08
data/lib/boojs/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module BooJS
2
- VERSION = '0.0.30'
2
+ VERSION = '0.0.31'
3
3
  end
data/lib/boojs.rb CHANGED
@@ -149,13 +149,6 @@ module BooJS
149
149
  puts p.pid
150
150
  end
151
151
 
152
- #Tell stdout that we did restart
153
- if pipe_restart
154
- pipe_restart = false
155
- puts "$__RESTART_OK__"
156
- $stdout.flush
157
- end
158
-
159
152
  loop do
160
153
  rr, _ = select([p, STDIN]); e = rr[0]
161
154
  #PhantomJS has written something
@@ -164,7 +157,17 @@ module BooJS
164
157
 
165
158
  if res =~ /STDIN_PORT/
166
159
  port = res.split(" ")[1].to_i
167
- start_server(port, @input_sender_r)
160
+ unless @in_port
161
+ start_server(@input_sender_r)
162
+ end
163
+ @in_port = port
164
+
165
+ #Tell stdout that we did restart
166
+ if pipe_restart
167
+ pipe_restart = false
168
+ puts "$__RESTART_OK__"
169
+ $stdout.flush
170
+ end
168
171
  else
169
172
  puts res
170
173
  $stdout.flush
@@ -175,6 +178,8 @@ module BooJS
175
178
  if e == STDIN
176
179
  res = e.readline
177
180
  if res == "$__RESTART__\n"
181
+ #You must wait several seconds for fsync
182
+ sleep 2
178
183
  pipe_restart = true
179
184
  raise PipeRestart
180
185
  else
@@ -195,14 +200,14 @@ module BooJS
195
200
  exit 1
196
201
  end
197
202
 
198
- def self.start_server port, pipe
203
+ def self.start_server pipe
199
204
  #Server that manages inputs
200
205
  Thread.new do
201
206
  begin
202
207
  loop do
203
208
  rr, __ = IO.select([@input_sender_r], []); e = rr[0]
204
209
 
205
- uri = URI.parse("http://localhost:#{port}")
210
+ uri = URI.parse("http://localhost:#{@in_port}")
206
211
  Net::HTTP.post_form(uri, {:str => e.readline})
207
212
  end
208
213
  rescue Exception => e
data/spec/persist_spec.rb CHANGED
@@ -51,17 +51,29 @@ RSpec.describe "Persist" do
51
51
 
52
52
  end
53
53
 
54
- it "Does persist during restarts" do
54
+ it "Does persist localStorage during restarts, but not variables" do
55
55
  Open3.popen3 "ruby -Ilib ./bin/boojs" do |i, o, e, t|
56
56
  begin
57
- i.puts "localStorage.setItem('foo', 'bar');"
57
+ secret = SecureRandom.hex
58
+ i.puts "localStorage.setItem('#{secret}', '#{secret}');"
59
+ i.puts "var x = 3;"
60
+ i.puts "console.log(typeof x === 'undefined');"
61
+ res = o.readline
62
+ expect(res).to eq("false\n")
63
+
64
+ #Now restart
58
65
  i.puts "$__RESTART__"
59
66
  res = o.readline
60
67
  expect(res).to eq("$__RESTART_OK__\n")
61
68
 
62
- i.puts "console.log(localStorage.getItem('foo'))"
69
+ i.puts "console.log(localStorage.getItem('#{secret}'))"
63
70
  res = o.readline
64
- expect(res).to eq("bar\n")
71
+ expect(res).to eq("#{secret}\n")
72
+
73
+ #X should no longer be set as we restart
74
+ i.puts "console.log(typeof x === 'undefined');"
75
+ res = o.readline
76
+ expect(res).to eq("true\n")
65
77
  ensure
66
78
  begin
67
79
  Process.kill :INT, t[:pid]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: boojs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.30
4
+ version: 0.0.31
5
5
  platform: ruby
6
6
  authors:
7
7
  - seo