Hi,
I am creating a listener/Directory Monitor to keep an eye on the changes to files in a particular directory using the Guard/Listen gem.
The examples I have been following all look more or less like the following:
# Create a callback
callback = Proc.new do |modified, added, removed|
# This proc will be called when there are changes.
end
listener = Listen.to('dir')
listener.change(&callback) # convert the callback to a block and register it
listener.startHowever, when I invoke my code which follows this exact format, it terminates immediately. I would expect it to sit there and listen for activity, but it doesn't. After looking through the documentation a bit, I discovered that `listener.start!` can be used instead of `listener.start`. Now, when I execute my script, it hangs in the terminal waiting for file system activity. The appropriate puts statements are fired when I modify files in the watched directory and so forth.
My question then, is why does the 'listener.start' not seem to work for me? All the examples use 'start' instead of 'start!'. I may just be completely missing something here, so I'd appreciate any explanation.