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). FSSM supports using FSEvents on MacOS, Inotify on GNU/Linux, and polling anywhere else.

  • 所有者: ttilley/fssm
  • 平台:
  • 许可证: MIT License
  • 分类:
  • 主题:
  • 喜欢:
    0
      比较:

Github星跟踪图

FSSM - currently unmaintained

endorse

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

Monitoring directories

By default, FSSM monitors changes in files only. To enable monitoring of files and directories, pass option directories => true in a hash to the monitor. Please note that this may not work as expected in all backends. For example:

FSSM::Monitor.new(:directories => true)
FSSM.monitor(dir, file_glob, :directories => true)

When directories are monitored, there's an additional third argument to the callbacks. Instead of

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

you get this:

FSSM.monitor('/some/directory/', '**/*', :directories => true) do
  update {, base, relative, type, }
  delete {, base, relative, type, }
  create {, base, relative, type, }
end

The value of type argument is either :file or :directory.

主要指标

概览
名称与所有者ttilley/fssm
主编程语言HTML
编程语言Ruby (语言数: 2)
平台
许可证MIT License
所有者活动
创建于2009-08-10 11:31:27
推送于2023-10-27 21:38:04
最后一次提交2016-11-02 07:51:28
发布数25
最新版本名称v0.2.10 (发布于 2013-01-27 02:12:18)
第一版名称v0.0.3 (发布于 )
用户参与
星数354
关注者数7
派生数27
提交数150
已启用问题?
问题数41
打开的问题数6
拉请求数4
打开的拉请求数4
关闭的拉请求数5
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?