Class BoxGrinder::FSMonitor
In: lib/boxgrinder-build/util/permissions/fs-monitor.rb
lib/boxgrinder-build/util/permissions/fs-monitor.rb
Parent: Object

Methods

add_path   add_path   capture   capture   new   new   reset   reset   stop   stop   trigger   trigger  

Included Modules

Singleton Observable Singleton Observable

Public Class methods

[Source]

    # 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

[Source]

    # 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

Public Instance methods

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.

[Source]

    # 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.

[Source]

    # 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.

[Source]

    # 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.

[Source]

    # 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

Stop any capturing and delete all observers. Useful for testing. @see stop

[Source]

    # File lib/boxgrinder-build/util/permissions/fs-monitor.rb, line 68
68:     def reset
69:       @lock_a.synchronize do
70:         _stop
71:         delete_observers
72:       end
73:     end

Stop any capturing and delete all observers. Useful for testing. @see stop

[Source]

    # File lib/boxgrinder-build/util/permissions/fs-monitor.rb, line 68
68:     def reset
69:       @lock_a.synchronize do
70:         _stop
71:         delete_observers
72:       end
73:     end

Explicitly stop capturing paths. This should be utilised if capture was not used with a block. Fires the +:stop_capture+ command to indicate that capturing has ceased.

[Source]

    # File lib/boxgrinder-build/util/permissions/fs-monitor.rb, line 62
62:     def stop
63:       @lock_a.synchronize { _stop }
64:     end

Explicitly stop capturing paths. This should be utilised if capture was not used with a block. Fires the +:stop_capture+ command to indicate that capturing has ceased.

[Source]

    # File lib/boxgrinder-build/util/permissions/fs-monitor.rb, line 62
62:     def stop
63:       @lock_a.synchronize { _stop }
64:     end

Trigger ownership change immediately, but without ceasing. Fires the +:chown+ command on all observers.

@return [boolean] False if no observers were present.

[Source]

    # 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.

[Source]

    # File lib/boxgrinder-build/util/permissions/fs-monitor.rb, line 95
95:     def trigger
96:       changed(true)
97:       notify_observers(:command => :chown)
98:     end

[Validate]