Skip to content

Commit

Permalink
[ci skip] document EventedFileUpdateChecker
Browse files Browse the repository at this point in the history
  • Loading branch information
schneems committed Jun 6, 2016
1 parent 7bd4199 commit bd38e92
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions activesupport/lib/active_support/evented_file_update_checker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,34 @@
require 'concurrent/atomic/atomic_boolean'

module ActiveSupport
# Allows you to "listen" to changes in a file system.
# The evented file updater does not hit disk when checking for updates
# instead it uses platform specific file system events to trigger a change
# in state.
#
# The file checker takes an array of files to watch or a hash specifying directories
# and file extensions to watch. It also takes a block that is called when
# EventedFileUpdateChecker#execute is run or when EventedFileUpdateChecker#execute_if_updated
# is run and there have been changes to the file system.
#
# Note: To start listening to change events you must first call
# EventedFileUpdateChecker#updated? inside of each process.
#
# Example:
#
# checker = EventedFileUpdateChecker.new(["/tmp/foo"], -> { puts "changed" })
# checker.updated?
# # => false
# checker.execute_if_updated
# # => nil
#
# FileUtils.touch("/tmp/foo")
#
# checker.updated?
# # => true
# checker.execute_if_updated
# # => "changed"
#
class EventedFileUpdateChecker #:nodoc: all
def initialize(files, dirs = {}, &block)
@ph = PathHelper.new
Expand Down

0 comments on commit bd38e92

Please sign in to comment.