class ActiveSupport::EventedFileUpdateChecker
def initialize(files, dirs = {}, &block)
# => "changed"
checker.execute_if_updated
# => true
checker.updated?
FileUtils.touch("/tmp/foo")
# => nil
checker.execute_if_updated
# => false
checker.updated?
checker = ActiveSupport::EventedFileUpdateChecker.new(["/tmp/foo"]) { puts "changed" }
Example:
is run and there have been changes to the file system.
EventedFileUpdateChecker#execute is run or when EventedFileUpdateChecker#execute_if_updated
and file extensions to watch. It also takes a block that is called when
The file checker takes an array of files to watch or a hash specifying directories
in state.
Instead, it uses platform-specific file system events to trigger a change
The evented file updater does not hit disk when checking for updates.
Allows you to "listen" to changes in a file system.
def initialize(files, dirs = {}, &block) unless block raise ArgumentError, "A block is required to initialize an EventedFileUpdateChecker" end @block = block @core = Core.new(files, dirs) ObjectSpace.define_finalizer(self, @core.finalizer) end