class ActiveSupport::EventedFileUpdateChecker
:nodoc: all
# => “changed”
checker.execute_if_updated
# => true
checker.updated?
FileUtils.touch(“/tmp/foo”)
# => nil
checker.execute_if_updated
# => false
checker.updated?
checker = ActiveSupport::EventedFileUpdateChecker.new() { 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 execute
def execute @core.updated.make_false @block.call end
def execute_if_updated
def execute_if_updated if updated? yield if block_given? execute true end end
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
def inspect
def inspect "#<ActiveSupport::EventedFileUpdateChecker:#{object_id} @files=#{@core.files.to_a.inspect}" end
def updated?
def updated? if @core.restart? @core.thread_safely(&:restart) @core.updated.make_true end @core.updated.true? end