hawkins 2.0.3 → 2.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/hawkins/liveserve.rb +22 -12
- data/lib/hawkins/version.rb +1 -1
- data/test/test_liveserve.rb +8 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f929af2fc50c880c9eddc8e616f2021356374156
|
4
|
+
data.tar.gz: eab14413e1a78b4153a341f66f68c0d653ab607f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9686c48fe8d922021257cec7f623c579f52b21f61de2988855549b94ee78502c86e6bffd3bc2c43a517cb271ea1d7899d55c65242325beb28c40f8279b76946b
|
7
|
+
data.tar.gz: 0bf0b78f452ef86dc79c0b23fdbe8d77eb123d8920c0e83be414adc25a4de137cfdb02123560e52ef80b5ca89b937d537638336e7a8a6148c14fce5de31315d9
|
data/lib/hawkins/liveserve.rb
CHANGED
@@ -3,6 +3,13 @@ require 'thread'
|
|
3
3
|
module Hawkins
|
4
4
|
module Commands
|
5
5
|
class LiveServe < Jekyll::Command
|
6
|
+
|
7
|
+
# Based on pattern described in
|
8
|
+
# https://emptysqua.re/blog/an-event-synchronization-primitive-for-ruby/
|
9
|
+
@mutex = Mutex.new
|
10
|
+
@running_cond = ConditionVariable.new
|
11
|
+
@is_running = false
|
12
|
+
|
6
13
|
class << self
|
7
14
|
COMMAND_OPTIONS = {
|
8
15
|
"swf" => ["--swf", "Use Flash for WebSockets support"],
|
@@ -14,6 +21,8 @@ module Hawkins
|
|
14
21
|
|
15
22
|
LIVERELOAD_PORT = 35729
|
16
23
|
|
24
|
+
attr_reader :mutex, :running_cond, :is_running
|
25
|
+
|
17
26
|
#
|
18
27
|
|
19
28
|
def init_with_program(prog)
|
@@ -51,7 +60,6 @@ module Hawkins
|
|
51
60
|
destination = opts["destination"]
|
52
61
|
setup(destination)
|
53
62
|
|
54
|
-
@running = Queue.new
|
55
63
|
@reload_reactor.start(opts)
|
56
64
|
|
57
65
|
@server = WEBrick::HTTPServer.new(webrick_opts(opts)).tap { |o| o.unmount("") }
|
@@ -65,12 +73,8 @@ module Hawkins
|
|
65
73
|
boot_or_detach(@server, opts)
|
66
74
|
end
|
67
75
|
|
68
|
-
def running?
|
69
|
-
!(@running.nil? || @running.empty?)
|
70
|
-
end
|
71
|
-
|
72
76
|
def shutdown
|
73
|
-
@server.shutdown if
|
77
|
+
@server.shutdown if @is_running
|
74
78
|
end
|
75
79
|
|
76
80
|
private
|
@@ -185,9 +189,9 @@ module Hawkins
|
|
185
189
|
private
|
186
190
|
def launch_browser(server, opts)
|
187
191
|
command =
|
188
|
-
if Utils::Platforms.windows?
|
192
|
+
if Jekyll::Utils::Platforms.windows?
|
189
193
|
"start"
|
190
|
-
elsif Utils::Platforms.osx?
|
194
|
+
elsif Jekyll::Utils::Platforms.osx?
|
191
195
|
"open"
|
192
196
|
else
|
193
197
|
"xdg-open"
|
@@ -255,8 +259,11 @@ module Hawkins
|
|
255
259
|
def start_callback(detached)
|
256
260
|
unless detached
|
257
261
|
proc do
|
258
|
-
|
259
|
-
|
262
|
+
mutex.synchronize do
|
263
|
+
@is_running = true
|
264
|
+
Jekyll.logger.info("Server running...", "press ctrl-c to stop.")
|
265
|
+
running_cond.signal
|
266
|
+
end
|
260
267
|
end
|
261
268
|
end
|
262
269
|
end
|
@@ -265,8 +272,11 @@ module Hawkins
|
|
265
272
|
def stop_callback(detached)
|
266
273
|
unless detached
|
267
274
|
proc do
|
268
|
-
|
269
|
-
|
275
|
+
mutex.synchronize do
|
276
|
+
@reload_reactor.stop unless @reload_reactor.nil?
|
277
|
+
@is_running = false
|
278
|
+
running_cond.signal
|
279
|
+
end
|
270
280
|
end
|
271
281
|
end
|
272
282
|
end
|
data/lib/hawkins/version.rb
CHANGED
data/test/test_liveserve.rb
CHANGED
@@ -57,8 +57,10 @@ module Hawkins
|
|
57
57
|
Commands::LiveServe.shutdown
|
58
58
|
end
|
59
59
|
|
60
|
-
|
61
|
-
|
60
|
+
Commands::LiveServe.mutex.synchronize do
|
61
|
+
if Commands::LiveServe.is_running
|
62
|
+
Commands::LiveServe.running_cond.wait(Commands::LiveServe.mutex)
|
63
|
+
end
|
62
64
|
end
|
63
65
|
|
64
66
|
FileUtils.remove_entry_secure(temp_dir, true)
|
@@ -69,8 +71,10 @@ module Hawkins
|
|
69
71
|
Commands::LiveServe.start(opts)
|
70
72
|
end
|
71
73
|
|
72
|
-
|
73
|
-
|
74
|
+
Commands::LiveServe.mutex.synchronize do
|
75
|
+
unless Commands::LiveServe.is_running
|
76
|
+
Commands::LiveServe.running_cond.wait(Commands::LiveServe.mutex)
|
77
|
+
end
|
74
78
|
end
|
75
79
|
end
|
76
80
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hawkins
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Wood
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-10-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|