smparkes-watchr 0.5.7.3 → 0.5.7.4

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.
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
- @monitored_paths = monitored_paths
93
- ::EM.run do
94
- attach
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
- sleep(0.1)
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.3'
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"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smparkes-watchr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.7.3
4
+ version: 0.5.7.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - mynyml