简体   繁体   English

使用rubyguard gem观看文件创建事件

[英]Watch file create events using ruby guard gem

如何使用Ruby guard Gem在特定文件夹中仅监视文件创建事件

You can create an inline Guard directly within your Guardfile : 您可以直接在Guardfile创建内联Guard:

module ::Guard
  class Test < Guard
    def run_on_additions(paths)
      puts "New paths: #{ paths.inspect }"
    end
  end
end

guard 'test'

You'll find the docs for the Guard plugin base class on rubydoc.info . 您可以在rubydoc.info上找到Guard插件基类的文档 If your inline Guard grows, you can create your own Guard plugin gem, see the Wiki page on how to create a Guard 如果内联Guard增长,则可以创建自己的Guard插件gem,请参阅Wiki页面上有关如何创建Guard的信息。

Another option is to use Listen directly, which is the file listener that was extracted from Guard. 另一个选择是直接使用“ 侦听” ,这是从Guard中提取的文件侦听器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM