Class: BoxGrinder::FSObserver

Inherits:
Object
  • Object
show all
Defined in:
lib/boxgrinder-build/util/permissions/fs-observer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user, group, opts = {}) ⇒ FSObserver

ownership of

Parameters:

  • user (Integer)

    The uid to switch from root to

  • group (Integer)

    The gid to switch from root to

  • opts (Hash) (defaults to: {})

    The options to create a observer with

Options Hash (opts):

  • :paths (Array<String>)

    Additional paths to change ownership of.

  • :paths (String)

    Additional path to to change



34
35
36
37
38
39
40
41
# 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

Instance Attribute Details

#filter_setObject

Returns the value of attribute filter_set.



25
26
27
# File 'lib/boxgrinder-build/util/permissions/fs-observer.rb', line 25

def filter_set
  @filter_set
end

#path_setObject

Returns the value of attribute path_set.



24
25
26
# File 'lib/boxgrinder-build/util/permissions/fs-observer.rb', line 24

def path_set
  @path_set
end

Instance Method Details

#update(update = {}) ⇒ Object

Receives updates from FSMonitor#add_path

Parameters:

  • opts (Hash)

    The options to update the observer



54
55
56
57
58
59
60
61
62
63
64
# 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