Skip to content

Instantly share code, notes, and snippets.

Created October 4, 2013 17:44
Show Gist options
  • Save anonymous/6829782 to your computer and use it in GitHub Desktop.
Save anonymous/6829782 to your computer and use it in GitHub Desktop.
1380908555 hi 6
1380908555 hi 6
1380908612 filegrapher.rb 552
1380908612 filegrapher.rb 552
1380908647 hi 1440
1380908647 hi 1440
#!/usr/bin/env ruby
# gems required - rb-inotify
require 'rb-inotify'
def handler(event)
File.open("data", "a") { |f| f.write "#{Time.now.to_i} #{event.absolute_name} #{File.size event.absolute_name}\n" }
end
notifier = INotify::Notifier.new
files = File.readlines('FILES').map { |a| a.strip! }
files.each do |file|
p "watching #{file}"
begin
notifier.watch file, :modify, :create, :delete, :delete_self do |event|
$stderr.puts event.absolute_name
handler event
end
rescue
p "error watching #{file}"
end
end
notifier.run
filegrapher.rb
test
hi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment