| Class | BoxGrinder::FSMonitor |
| In: |
lib/boxgrinder-build/util/permissions/fs-monitor.rb
lib/boxgrinder-build/util/permissions/fs-monitor.rb |
| Parent: | Object |
# File lib/boxgrinder-build/util/permissions/fs-monitor.rb, line 31
31: def initialize
32: @flag = GetSet.new
33: @lock_a = Mutex.new
34: @lock_b = Mutex.new
35: set_hooks
36: end
# File lib/boxgrinder-build/util/permissions/fs-monitor.rb, line 31
31: def initialize
32: @flag = GetSet.new
33: @lock_a = Mutex.new
34: @lock_b = Mutex.new
35: set_hooks
36: end
Add a path string. Called by the hooked methods when an applicable action is triggered and capturing is enabled. Fires the +:add_path+ command, and includes the full path as +:data+.
If no observers have been assigned before a path is added, they will be silently lost.
@param [String] path Filesystem path. @return [Boolean] False if no observers were present.
# File lib/boxgrinder-build/util/permissions/fs-monitor.rb, line 84
84: def add_path(path)
85: @lock_b.synchronize do
86: changed(true)
87: notify_observers(:command => :add_path, :data => realpath(path))
88: end
89: end
Add a path string. Called by the hooked methods when an applicable action is triggered and capturing is enabled. Fires the +:add_path+ command, and includes the full path as +:data+.
If no observers have been assigned before a path is added, they will be silently lost.
@param [String] path Filesystem path. @return [Boolean] False if no observers were present.
# File lib/boxgrinder-build/util/permissions/fs-monitor.rb, line 84
84: def add_path(path)
85: @lock_b.synchronize do
86: changed(true)
87: notify_observers(:command => :add_path, :data => realpath(path))
88: end
89: end
Start capturing paths. Providing a block automatically stops the capture process upon termination of the scope.
@param Array<update> Observers to be notified of capture
events. Each observer should expect a hash{} containing a
+:command+, and potentially +:data+.
@yield Block that automatically calls stop at the end of scope
to cease capture.
# File lib/boxgrinder-build/util/permissions/fs-monitor.rb, line 47
47: def capture(*observers, &block)
48: @lock_a.synchronize do
49: add_observers(observers)
50: _capture(&block)
51:
52: if block_given?
53: yield
54: _stop
55: end
56: end
57: end
Start capturing paths. Providing a block automatically stops the capture process upon termination of the scope.
@param Array<update> Observers to be notified of capture
events. Each observer should expect a hash{} containing a
+:command+, and potentially +:data+.
@yield Block that automatically calls stop at the end of scope
to cease capture.
# File lib/boxgrinder-build/util/permissions/fs-monitor.rb, line 47
47: def capture(*observers, &block)
48: @lock_a.synchronize do
49: add_observers(observers)
50: _capture(&block)
51:
52: if block_given?
53: yield
54: _stop
55: end
56: end
57: end
Trigger ownership change immediately, but without ceasing. Fires the +:chown+ command on all observers.
@return [boolean] False if no observers were present.
# File lib/boxgrinder-build/util/permissions/fs-monitor.rb, line 95
95: def trigger
96: changed(true)
97: notify_observers(:command => :chown)
98: end
Trigger ownership change immediately, but without ceasing. Fires the +:chown+ command on all observers.
@return [boolean] False if no observers were present.
# File lib/boxgrinder-build/util/permissions/fs-monitor.rb, line 95
95: def trigger
96: changed(true)
97: notify_observers(:command => :chown)
98: end