Class | BoxGrinder::FSObserver |
In: |
lib/boxgrinder-build/util/permissions/fs-observer.rb
lib/boxgrinder-build/util/permissions/fs-observer.rb |
Parent: | Object |
filter_set | [RW] | |
filter_set | [RW] | |
path_set | [RW] | |
path_set | [RW] |
@param [Integer] user The uid to switch from root to @param [Integer] group The gid to switch from root to @param [Hash] opts The options to create a observer with @option opts [Array<String>] :paths Additional paths to change
ownership of.
@option opts [String] :paths Additional path to to change ownership of
# File lib/boxgrinder-build/util/permissions/fs-observer.rb, line 34 34: def initialize(user, group, opts={}) 35: @path_set = Set.new(Array(opts[:paths])) 36: # Filter some default directories, plus any subdirectories of 37: # paths we discover at runtime 38: @filter_set = Set.new([%r(^/(etc|dev|sys|bin|sbin|etc|lib|lib64|boot|run|proc|selinux|tmp)(/|$))]) 39: @user = user 40: @group = group 41: end
@param [Integer] user The uid to switch from root to @param [Integer] group The gid to switch from root to @param [Hash] opts The options to create a observer with @option opts [Array<String>] :paths Additional paths to change
ownership of.
@option opts [String] :paths Additional path to to change ownership of
# File lib/boxgrinder-build/util/permissions/fs-observer.rb, line 34 34: def initialize(user, group, opts={}) 35: @path_set = Set.new(Array(opts[:paths])) 36: # Filter some default directories, plus any subdirectories of 37: # paths we discover at runtime 38: @filter_set = Set.new([%r(^/(etc|dev|sys|bin|sbin|etc|lib|lib64|boot|run|proc|selinux|tmp)(/|$))]) 39: @user = user 40: @group = group 41: end
Receives updates from FSMonitor#add_path
@param [Hash] opts The options to update the observer @option opts [:symbol] :command The command to instruct the
observer to execute. * +:add_path+ Indicates the +:data+ field contains a path. * +:stop_capture+ indicates that capturing has ceased. The observer will change ownership of the files, and switch to the user specified at #initialize.
@option opts [String] :data Contains a resource path when the
* +:add_path+ Command is called, otherwise ignored.
# File lib/boxgrinder-build/util/permissions/fs-observer.rb, line 54 54: def update(update={}) 55: case update[:command] 56: when :add_path 57: unless match_filter?(update[:data]) 58: @path_set.add(update[:data]) 59: @filter_set.merge(subdirectory_regex(update[:data])) 60: end 61: when :stop_capture, :chown 62: do_chown 63: end 64: end
Receives updates from FSMonitor#add_path
@param [Hash] opts The options to update the observer @option opts [:symbol] :command The command to instruct the
observer to execute. * +:add_path+ Indicates the +:data+ field contains a path. * +:stop_capture+ indicates that capturing has ceased. The observer will change ownership of the files, and switch to the user specified at #initialize.
@option opts [String] :data Contains a resource path when the
* +:add_path+ Command is called, otherwise ignored.
# File lib/boxgrinder-build/util/permissions/fs-observer.rb, line 54 54: def update(update={}) 55: case update[:command] 56: when :add_path 57: unless match_filter?(update[:data]) 58: @path_set.add(update[:data]) 59: @filter_set.merge(subdirectory_regex(update[:data])) 60: end 61: when :stop_capture, :chown 62: do_chown 63: end 64: end