boojs 0.0.30 → 0.0.31
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/boojs/version.rb +1 -1
- data/lib/boojs.rb +15 -10
- data/spec/persist_spec.rb +16 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 96ee4c56f3d5b80a75b2d084e1c56039dc834e5f
|
4
|
+
data.tar.gz: e044ad6d195d8565faeed8838fd2c8d2bb83a9a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 16d8523cbe1210b08f194ebee09fc74be614163fced0f057e5cabfe650ea377ec012752e7cd7659ae9ef122d07488b2ad9671a4a9a277a58ef4c8e02351bf03f
|
7
|
+
data.tar.gz: 618c00d39140585d135f05e39745fe43208c48f95dceff18a6a58855dd5aeb32ed993bd56f2cf78b5c5ae0f2a57eb3808617c507d73dbf8563e320a479cb8e08
|
data/lib/boojs/version.rb
CHANGED
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
|
-
|
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
|
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:#{
|
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
|
-
|
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('
|
69
|
+
i.puts "console.log(localStorage.getItem('#{secret}'))"
|
63
70
|
res = o.readline
|
64
|
-
expect(res).to eq("
|
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]
|