Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add first example

  • Loading branch information...
commit 10333f42f1cdc341f475d98898521bb677821fdc 1 parent f8950cc
@aredridel aredridel authored
Showing with 30 additions and 0 deletions.
  1. +30 −0 examples/watcher.rb
View
30 examples/watcher.rb
@@ -0,0 +1,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
Please sign in to comment.
Something went wrong with that request. Please try again.