aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorschneems <richard.schneeman@gmail.com>2016-06-06 11:26:50 -0500
committerschneems <richard.schneeman@gmail.com>2016-06-06 11:34:39 -0500
commitbd38e92b41e055d107f4e4af8b60dfa6a38f444a (patch)
treec4acaab2a78e9d56be448bf1608b29f61b3c9aee /activesupport
parent7bd41994480c17db71fdc07e3447ade929eaa386 (diff)
downloadrails-bd38e92b41e055d107f4e4af8b60dfa6a38f444a.tar.gz
rails-bd38e92b41e055d107f4e4af8b60dfa6a38f444a.tar.bz2
rails-bd38e92b41e055d107f4e4af8b60dfa6a38f444a.zip
[ci skip] document EventedFileUpdateChecker
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/evented_file_update_checker.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/evented_file_update_checker.rb b/activesupport/lib/active_support/evented_file_update_checker.rb
index f549ce4040..c0ad21b0df 100644
--- a/activesupport/lib/active_support/evented_file_update_checker.rb
+++ b/activesupport/lib/active_support/evented_file_update_checker.rb
@@ -3,6 +3,34 @@ require 'pathname'
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