Last active
July 11, 2018 14:55
-
-
Save e2/11251178 to your computer and use it in GitHub Desktop.
Script for testing inotify and listen on Linux
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gem "rb-inotify" | |
require 'rb-inotify' | |
gem "listen" | |
require "listen" | |
dir = '.' | |
Listen.to(dir) do |modified, added, removed| | |
puts "listen: #{[added, modified, removed].inspect}!" | |
end.start | |
events = [:recursive, :attrib, :create, :delete, :move, :close_write] | |
INotify::Notifier.new.tap do |notifier| | |
notifier.watch(dir, *events) do |event| | |
puts "rb-inotify event: #{event.name} #{event.flags.inspect}" | |
end | |
notifier.run | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment