/usr/share/doc/ruby-inotify/examples/watcher.rb is in ruby-inotify 0.0.2-7.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | #!usr/bin/ruby
require 'inotify'
require 'find'
i = Inotify.new
t = Thread.new do
i.each_event do |ev|
p ev.name
p ev.mask
end
end
raise("Specify a directory") if !ARGV[0]
Find.find(ARGV[0]) do |e|
if ['.svn', 'CVS', 'RCS'].include? File.basename(e) or !File.directory? e
Find.prune
else
begin
puts "Adding #{e}"
i.add_watch(e, Inotify::CREATE | Inotify::DELETE | Inotify::MOVE)
rescue
puts "Skipping #{e}: #{$!}"
end
end
end
t.join
|