class BoxGrinder::FSObserver

Attributes

filter_set[RW]
path_set[RW]

Public Class Methods

new(user, group, opts={}) click to toggle source

@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
def initialize(user, group, opts={})
  @path_set = Set.new(Array(opts[:paths]))
  # Filter some default directories, plus any subdirectories of
  # paths we discover at runtime
  @filter_set = Set.new([%r(^/(etc|dev|sys|bin|sbin|etc|lib|lib64|boot|run|proc|selinux|tmp)(/|$))])
  @user = user
  @group = group
end

Public Instance Methods

update(update={}) click to toggle source

Receives updates from BoxGrinder::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
def update(update={})
  case update[:command]
    when :add_path
      unless match_filter?(update[:data])
        @path_set.add(update[:data])
        @filter_set.merge(subdirectory_regex(update[:data]))
      end
    when :stop_capture, :chown
      do_chown
  end
end