ttilley/fssm
关于
文件系统状态监视器可跟踪任意数量路径的状态,并在状态发生变化(创建、更新或删除)时触发事件。FSSM 在 MacOS 上支持 FSEvents,在 GNU/Linux 上支持 Inotify,其他平台则使用轮询。
系统与基础设施实测星标增长
- 24小时
- 0
- 7天
- 0
- 15天
- 0
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文FSSM - currently unmaintained
Monitor API
There are three ways you can run the monitor.
- Call monitor with a path parameter, and define callbacks in a block
- Call monitor with a block to configure multiple paths and callbacks
- 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.
探索相关项目
加载中…
