【问题标题】:Watch file create events using ruby guard gem使用 ruby​​ 保护 gem 监视文件创建事件
【发布时间】:2012-08-14 08:19:00
【问题描述】:

如何使用 Ruby guard gem 在特定文件夹中仅查看文件创建事件

【问题讨论】:

    标签: ruby guard


    【解决方案1】:

    您可以直接在您的 Guardfile 中创建内联 Guard:

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

    您可以在 rubydoc.info 上找到 Guard 插件基类的文档。如果您的内联 Guard 增长,您可以创建自己的 Guard 插件 gem,请参阅 Wiki 页面了解如何create a Guard

    另一种选择是直接使用Listen,这是从Guard中提取的文件监听器。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-05-02
      • 2014-05-17
      • 1970-01-01
      • 2015-01-30
      • 2020-09-30
      • 2015-10-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多