y2p
y2p

Reputation: 4941

Watch file create events using ruby guard gem

How do I watch for only the file create events in a particular folder using Ruby guard gem

Upvotes: 1

Views: 1076

Answers (1)

Netzpirat
Netzpirat

Reputation: 5501

You can create an inline Guard directly within your Guardfile:

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. If your inline Guard grows, you can create your own Guard plugin gem, see the Wiki page on how to create a Guard

Another option is to use Listen directly, which is the file listener that was extracted from Guard.

Upvotes: 1

Related Questions