T
Tony Arcieri
[Note: parts of this message were removed to make it a legal post.]
Rev is a high-performance event library for Ruby, providing event loops for
monitoring network, timer, and now filesystem events. Rev is based on the
libev C library.
http://github.com/tarcieri/rev/
Rev 0.3.0 provides some bugfixes and performance improvements as well as a
slew of new features, including many new extensions to existing APIs that
provide for better integration with the Ruby environment, and a new
filesystem monitoring API built on the facilities provided by the libev
event library, including inotify support on Linux.
The new StatWatcher API allows you to monitor any file or directory for
changes and receive events when changes occur:
-- snip --
class MyStatWatcher < Rev::StatWatcher
def on_change
begin
puts "#{path} has new status #{File.stat(path).inspect}"
rescue Errno::ENOENT
puts "#{path} was deleted"
end
end
end
watcher = MyStatWatcher.new "interesting/file"
watcher.attach Rev::Loop.default
Rev::Loop.default.run
-- snip --
I know there are many gems already available to provide filesystem
monitoring, such as directory_watcher (
http://github.com/TwP/directory_watcher/tree/master), and that EventMachine
already provides EM.watch_file, but for the Rev users out there, you now
have the same capabilities with Rev's asynchronous event loops.
Rev is a high-performance event library for Ruby, providing event loops for
monitoring network, timer, and now filesystem events. Rev is based on the
libev C library.
http://github.com/tarcieri/rev/
Rev 0.3.0 provides some bugfixes and performance improvements as well as a
slew of new features, including many new extensions to existing APIs that
provide for better integration with the Ruby environment, and a new
filesystem monitoring API built on the facilities provided by the libev
event library, including inotify support on Linux.
The new StatWatcher API allows you to monitor any file or directory for
changes and receive events when changes occur:
-- snip --
class MyStatWatcher < Rev::StatWatcher
def on_change
begin
puts "#{path} has new status #{File.stat(path).inspect}"
rescue Errno::ENOENT
puts "#{path} was deleted"
end
end
end
watcher = MyStatWatcher.new "interesting/file"
watcher.attach Rev::Loop.default
Rev::Loop.default.run
-- snip --
I know there are many gems already available to provide filesystem
monitoring, such as directory_watcher (
http://github.com/TwP/directory_watcher/tree/master), and that EventMachine
already provides EM.watch_file, but for the Rev users out there, you now
have the same capabilities with Rev's asynchronous event loops.