smparkes-watchr 0.5.7.3 → 0.5.7.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +3 -1
- data/lib/watchr/event_handlers/em.rb +27 -4
- data/lib/watchr/script.rb +7 -1
- data/watchr.gemspec +1 -1
- metadata +1 -1
data/README.rdoc
CHANGED
@@ -90,4 +90,6 @@ first started, similar to what autotest does.
|
|
90
90
|
|
91
91
|
1. Handle user interrupt processing more systematically
|
92
92
|
|
93
|
-
1. Perhaps add the event type to the watch callback, since multiple events can fire now. But haven't neede this.
|
93
|
+
1. Perhaps add the event type to the watch callback, since multiple events can fire now. But haven't neede this.
|
94
|
+
|
95
|
+
1. Don't swallow config file error messages (particularly on reload)
|
@@ -42,14 +42,20 @@ module Watchr
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def file_moved
|
45
|
+
SingleFileWatcher.handler.forget self, path
|
45
46
|
stop_watching
|
46
47
|
SingleFileWatcher.handler.notify(path, type)
|
47
48
|
end
|
48
49
|
|
49
50
|
def file_deleted
|
51
|
+
SingleFileWatcher.handler.forget self, path
|
50
52
|
SingleFileWatcher.handler.notify(path, type)
|
51
53
|
end
|
52
54
|
|
55
|
+
def stop
|
56
|
+
stop_watching
|
57
|
+
end
|
58
|
+
|
53
59
|
private
|
54
60
|
|
55
61
|
def update_reference_times
|
@@ -89,9 +95,15 @@ module Watchr
|
|
89
95
|
# Will block control flow until application is explicitly stopped/killed.
|
90
96
|
#
|
91
97
|
def listen(monitored_paths)
|
92
|
-
|
93
|
-
|
94
|
-
|
98
|
+
# FIX ... make more generic (handle at a higher level ...)
|
99
|
+
while true
|
100
|
+
@monitored_paths = monitored_paths
|
101
|
+
@old_paths = []
|
102
|
+
@first_time = true
|
103
|
+
@watchers = {}
|
104
|
+
::EM.run do
|
105
|
+
attach
|
106
|
+
end
|
95
107
|
end
|
96
108
|
end
|
97
109
|
|
@@ -104,6 +116,14 @@ module Watchr
|
|
104
116
|
attach
|
105
117
|
end
|
106
118
|
|
119
|
+
def forget connection, path
|
120
|
+
if @watchers[path] != connection
|
121
|
+
$stderr.puts \
|
122
|
+
"warning: no/wrong watcher to forget for #{path}: #{@watchers[path]} vs #{connection}"
|
123
|
+
end
|
124
|
+
@watchers.delete path
|
125
|
+
end
|
126
|
+
|
107
127
|
private
|
108
128
|
|
109
129
|
# Binds all <tt>monitored_paths</tt> to the listening loop.
|
@@ -116,9 +136,12 @@ module Watchr
|
|
116
136
|
# p "new", new_paths
|
117
137
|
raise "hell" if @monitored_paths.length == 1
|
118
138
|
new_paths.each do |path|
|
139
|
+
if @watchers[path]
|
140
|
+
$stderr.puts "warning: replacing (ignoring) watcher for #{path}"
|
141
|
+
# @watchers[path].stop
|
142
|
+
end
|
119
143
|
::EM.watch_file path.to_s, SingleFileWatcher do |watcher|
|
120
144
|
watcher.init @first_time
|
121
|
-
raise "hell" if @watchers[path]
|
122
145
|
@watchers[path] = watcher
|
123
146
|
end
|
124
147
|
end
|
data/lib/watchr/script.rb
CHANGED
@@ -133,7 +133,13 @@ module Watchr
|
|
133
133
|
# Should probably use a watchdog timer that gets reset on every change and then only fire actions
|
134
134
|
# after the watchdog timer fires without get reset ..
|
135
135
|
|
136
|
-
|
136
|
+
v = nil
|
137
|
+
(1..10).each do
|
138
|
+
old_v = v
|
139
|
+
v = @path.read
|
140
|
+
break if v && v == old_v
|
141
|
+
sleep(0.2)
|
142
|
+
end
|
137
143
|
|
138
144
|
instance_eval(@path.read)
|
139
145
|
|
data/watchr.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
|
2
2
|
Gem::Specification.new do |s|
|
3
3
|
s.name = 'smparkes-watchr'
|
4
|
-
s.version = '0.5.7.
|
4
|
+
s.version = '0.5.7.4'
|
5
5
|
s.summary = "Modern continious testing (flexible alternative to autotest)"
|
6
6
|
s.description = "Modern continious testing (flexible alternative to autotest)."
|
7
7
|
s.author = "mynyml"
|