rerun 0.7.0.pre4 → 0.7.0.pre5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/rerun/runner.rb +20 -7
- data/rerun.gemspec +1 -1
- metadata +2 -2
data/lib/rerun/runner.rb
CHANGED
@@ -18,9 +18,7 @@ module Rerun
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def start_keypress_thread
|
21
|
-
from = caller.first
|
22
21
|
@keypress_thread = Thread.new do
|
23
|
-
# puts "starting keypress thread #{Thread.current.object_id} from #{from}"
|
24
22
|
while true
|
25
23
|
if c = key_pressed
|
26
24
|
case c.downcase
|
@@ -30,10 +28,17 @@ module Rerun
|
|
30
28
|
when 'r'
|
31
29
|
say "Restarting"
|
32
30
|
restart
|
33
|
-
break # the break will stop this thread
|
34
31
|
when 'x', 'q'
|
35
32
|
die
|
36
33
|
break # the break will stop this thread, in case the 'die' doesn't
|
34
|
+
when 't'
|
35
|
+
puts
|
36
|
+
puts "#{Thread.list.size} threads:"
|
37
|
+
Thread.list.each do |t|
|
38
|
+
puts "#{t.object_id}\tstatus: #{t.status}"
|
39
|
+
puts "\t" + t.backtrace[0..5].join("\n\t")
|
40
|
+
puts
|
41
|
+
end
|
37
42
|
else
|
38
43
|
puts "\n#{c.inspect} pressed inside rerun"
|
39
44
|
puts [["c", "clear screen"],
|
@@ -45,12 +50,11 @@ module Rerun
|
|
45
50
|
end
|
46
51
|
sleep 1 # todo: use select instead of polling somehow?
|
47
52
|
end
|
48
|
-
# puts "keypress thread #{Thread.current.object_id} ending"
|
49
53
|
end
|
50
54
|
@keypress_thread.run
|
51
55
|
end
|
52
56
|
|
53
|
-
def
|
57
|
+
def stop_keypress_thread
|
54
58
|
@keypress_thread.kill if @keypress_thread
|
55
59
|
@keypress_thread = nil
|
56
60
|
end
|
@@ -101,7 +105,7 @@ module Rerun
|
|
101
105
|
end
|
102
106
|
|
103
107
|
clear_screen if clear?
|
104
|
-
start_keypress_thread
|
108
|
+
start_keypress_thread unless @keypress_thread
|
105
109
|
|
106
110
|
@pid = Kernel.fork do
|
107
111
|
begin
|
@@ -144,7 +148,15 @@ module Rerun
|
|
144
148
|
|
145
149
|
unless @watcher
|
146
150
|
|
147
|
-
watcher = Watcher.new(:directory => dir, :pattern => pattern) do
|
151
|
+
watcher = Watcher.new(:directory => dir, :pattern => pattern) do |changes|
|
152
|
+
|
153
|
+
message = [:modified, :added, :removed].map do |change|
|
154
|
+
count = changes[change].size
|
155
|
+
if count and count > 0
|
156
|
+
"#{count} #{change}"
|
157
|
+
end
|
158
|
+
end.compact.join(", ")
|
159
|
+
say "Change detected: #{message}"
|
148
160
|
restart unless @restarting
|
149
161
|
end
|
150
162
|
watcher.start
|
@@ -154,6 +166,7 @@ module Rerun
|
|
154
166
|
end
|
155
167
|
|
156
168
|
def die
|
169
|
+
#stop_keypress_thread # don't do this since we're probably *in* the keypress thread
|
157
170
|
stop # stop the child process if it exists
|
158
171
|
exit 0 # todo: status code param
|
159
172
|
end
|
data/rerun.gemspec
CHANGED
@@ -3,7 +3,7 @@ $spec = Gem::Specification.new do |s|
|
|
3
3
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
4
4
|
|
5
5
|
s.name = 'rerun'
|
6
|
-
s.version = '0.7.0.
|
6
|
+
s.version = '0.7.0.pre5'
|
7
7
|
|
8
8
|
s.description = "Restarts your app when a file changes"
|
9
9
|
s.summary = "Launches an app, and restarts it whenever the filesystem changes."
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rerun
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.0.
|
4
|
+
version: 0.7.0.pre5
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -61,7 +61,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
61
61
|
version: '0'
|
62
62
|
segments:
|
63
63
|
- 0
|
64
|
-
hash: -
|
64
|
+
hash: -1590261424703509507
|
65
65
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
66
|
none: false
|
67
67
|
requirements:
|