chriseppstein / fssm forked from ttilley/fssm

The File System State Monitor keeps track of the state of any number of paths and will fire events when said state changes (create/update/delete). Currently, FSSM supports using FSEvents on MacOS and polling anywhere else. Support for inotify on linux is planned.

This URL has Read+Write access

fssm /
name age message
file .document Sun Aug 09 06:43:47 -0700 2009 Initial commit to fsstate. [ttilley]
file .gitignore Loading commit data...
file LICENSE Sun Aug 09 06:43:47 -0700 2009 Initial commit to fsstate. [ttilley]
file README.markdown Sat Aug 29 23:02:07 -0700 2009 lets try this again [ttilley]
file Rakefile
file VERSION.yml
directory lib/
directory spec/
README.markdown

Monitor API

There are three ways you can run the monitor.

  1. call monitor with a path parameter, and define callbacks in a block
  2. call monitor with a block to configure multiple paths and callbacks
  3. create a monitor object and run each step manually

Monitor with path

This form watches one path, and enters the run loop automatically. The first parameter is the path to watch, and the second parameter is an optional glob pattern or array of glob patterns that a file must match in order to trigger a callback. The default glob, if ommitted, is '**/*'.

FSSM.monitor('/some/directory/', '**/*') do
  update {|base, relative|}
  delete {|base, relative|}
  create {|base, relative|}
end

Monitor with block

This form watches one or more paths, and enters the run loop automatically. The glob configuration call can be ommitted, and defaults to '**/*'.

FSSM.monitor do
  path '/some/directory/' do
    glob '**/*.yml'

    update {|base, relative|}
    delete {|base, relative|}
    create {|base, relative|}
  end

  path '/some/other/directory/' do
    update {|base, relative|}
    delete {|base, relative|}
    create {|base, relative|}
  end
end

Monitor object

This form doesn't enter the run loop automatically.

monitor = FSSM::Monitor.new

monitor.path '/some/directory/' do
  update {|base, relative|}
  delete {|base, relative|}
  create {|base, relative|}
end

monitor.run