File: watcher.rb

package info (click to toggle)
libinotify-ruby 0.0.2-5
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 112 kB
  • ctags: 72
  • sloc: ansic: 236; ruby: 64; makefile: 6
file content (30 lines) | stat: -rw-r--r-- 466 bytes parent folder | download | duplicates (3)
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