directory_watcher 0.1.4 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +3 -0
- data/lib/directory_watcher.rb +22 -20
- metadata +2 -2
data/Rakefile
CHANGED
@@ -19,6 +19,9 @@ dispatched to registered observers. Three types of events are supported --
|
|
19
19
|
added, modified, and removed.
|
20
20
|
DESC
|
21
21
|
proj.changes = <<-CHANGES
|
22
|
+
Version 1.0.0 / 2007-08-21
|
23
|
+
* added a join method (much like Thread#join)
|
24
|
+
|
22
25
|
Version 0.1.4 / 2007-08-20
|
23
26
|
* added version information to the class
|
24
27
|
|
data/lib/directory_watcher.rb
CHANGED
@@ -6,7 +6,6 @@
|
|
6
6
|
|
7
7
|
require 'observer'
|
8
8
|
|
9
|
-
#
|
10
9
|
# == Synopsis
|
11
10
|
#
|
12
11
|
# A class for watching files within a directory and generating events when
|
@@ -152,9 +151,8 @@ require 'observer'
|
|
152
151
|
class DirectoryWatcher
|
153
152
|
include Observable
|
154
153
|
|
155
|
-
VERSION = '0.
|
154
|
+
VERSION = '1.0.0' # :nodoc:
|
156
155
|
|
157
|
-
#
|
158
156
|
# An +Event+ structure contains the _type_ of the event and the file _path_
|
159
157
|
# to which the event pertains. The type can be one of the following:
|
160
158
|
#
|
@@ -172,7 +170,6 @@ class DirectoryWatcher
|
|
172
170
|
end
|
173
171
|
# :startdoc:
|
174
172
|
|
175
|
-
#
|
176
173
|
# call-seq:
|
177
174
|
# DirectoryWatcher.new( directory, options )
|
178
175
|
#
|
@@ -215,13 +212,13 @@ class DirectoryWatcher
|
|
215
212
|
@thread = nil
|
216
213
|
end
|
217
214
|
|
218
|
-
#
|
219
215
|
# call-seq:
|
220
216
|
# add_observer( observer )
|
221
|
-
# add_observer {|*
|
217
|
+
# add_observer {|*events| block}
|
222
218
|
#
|
223
219
|
# Adds the given _observer_ as an observer on this directory watcher. The
|
224
|
-
# _observer_ will now receive file events when they are generated.
|
220
|
+
# _observer_ will now receive file events when they are generated. The
|
221
|
+
# _observer_ must implement an <code>update( *events )</code> method.
|
225
222
|
#
|
226
223
|
# Optionally, a block can be passed as the observer. The block will be
|
227
224
|
# executed with the file events passed as the arguments. A reference to the
|
@@ -238,7 +235,6 @@ class DirectoryWatcher
|
|
238
235
|
super observer
|
239
236
|
end
|
240
237
|
|
241
|
-
#
|
242
238
|
# call-seq:
|
243
239
|
# glob = '*'
|
244
240
|
# glob = ['lib/**/*.rb', 'test/**/*.rb']
|
@@ -259,7 +255,6 @@ class DirectoryWatcher
|
|
259
255
|
end
|
260
256
|
attr_reader :glob
|
261
257
|
|
262
|
-
#
|
263
258
|
# call-seq:
|
264
259
|
# interval = 30.0
|
265
260
|
#
|
@@ -274,7 +269,6 @@ class DirectoryWatcher
|
|
274
269
|
end
|
275
270
|
attr_reader :interval
|
276
271
|
|
277
|
-
#
|
278
272
|
# call-seq:
|
279
273
|
# stable = 2
|
280
274
|
#
|
@@ -310,7 +304,6 @@ class DirectoryWatcher
|
|
310
304
|
end
|
311
305
|
attr_reader :stable
|
312
306
|
|
313
|
-
#
|
314
307
|
# call-seq:
|
315
308
|
# running?
|
316
309
|
#
|
@@ -321,7 +314,6 @@ class DirectoryWatcher
|
|
321
314
|
!@thread.nil?
|
322
315
|
end
|
323
316
|
|
324
|
-
#
|
325
317
|
# call-seq:
|
326
318
|
# start
|
327
319
|
#
|
@@ -336,7 +328,6 @@ class DirectoryWatcher
|
|
336
328
|
self
|
337
329
|
end
|
338
330
|
|
339
|
-
#
|
340
331
|
# call-seq:
|
341
332
|
# stop
|
342
333
|
#
|
@@ -353,7 +344,6 @@ class DirectoryWatcher
|
|
353
344
|
self
|
354
345
|
end
|
355
346
|
|
356
|
-
#
|
357
347
|
# call-seq:
|
358
348
|
# reset( pre_load = false )
|
359
349
|
#
|
@@ -372,8 +362,25 @@ class DirectoryWatcher
|
|
372
362
|
start if was_running
|
373
363
|
end
|
374
364
|
|
375
|
-
|
365
|
+
# call-seq:
|
366
|
+
# join( limit = nil )
|
376
367
|
#
|
368
|
+
# If the directory watcher is running, the calling thread will suspend
|
369
|
+
# execution and run the directory watcher thread. This method does not
|
370
|
+
# return until the directory watcher is stopped or until _limit_ seconds
|
371
|
+
# have passed.
|
372
|
+
#
|
373
|
+
# If the directory watcher is not running, this method returns immediately
|
374
|
+
# with +nil+.
|
375
|
+
#
|
376
|
+
def join( limit = nil )
|
377
|
+
return unless running?
|
378
|
+
@thread.join limit
|
379
|
+
end
|
380
|
+
|
381
|
+
|
382
|
+
private
|
383
|
+
|
377
384
|
# call-seq:
|
378
385
|
# scan_files
|
379
386
|
#
|
@@ -395,7 +402,6 @@ class DirectoryWatcher
|
|
395
402
|
files
|
396
403
|
end
|
397
404
|
|
398
|
-
#
|
399
405
|
# call-seq:
|
400
406
|
# run
|
401
407
|
#
|
@@ -424,7 +430,6 @@ class DirectoryWatcher
|
|
424
430
|
end
|
425
431
|
end
|
426
432
|
|
427
|
-
#
|
428
433
|
# call-seq:
|
429
434
|
# find_added( files, cur, prev )
|
430
435
|
#
|
@@ -441,7 +446,6 @@ class DirectoryWatcher
|
|
441
446
|
self
|
442
447
|
end
|
443
448
|
|
444
|
-
#
|
445
449
|
# call-seq:
|
446
450
|
# find_removed( cur, prev )
|
447
451
|
#
|
@@ -455,7 +459,6 @@ class DirectoryWatcher
|
|
455
459
|
self
|
456
460
|
end
|
457
461
|
|
458
|
-
#
|
459
462
|
# call-seq:
|
460
463
|
# find_modified( files, cur, prev )
|
461
464
|
#
|
@@ -489,7 +492,6 @@ class DirectoryWatcher
|
|
489
492
|
self
|
490
493
|
end
|
491
494
|
|
492
|
-
#
|
493
495
|
# call-seq:
|
494
496
|
# notify_observers
|
495
497
|
#
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
|
|
3
3
|
specification_version: 1
|
4
4
|
name: directory_watcher
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.
|
7
|
-
date: 2007-08-
|
6
|
+
version: 1.0.0
|
7
|
+
date: 2007-08-21 00:00:00 -06:00
|
8
8
|
summary: A class for watching files within a directory and generating events when those files change
|
9
9
|
require_paths:
|
10
10
|
- lib
|