Module: FunWith::Files::FilePermissionMethods

Defined in:
lib/fun_with/files/file_permission_methods.rb

Overview

view and change file permissions

Instance Method Summary collapse

Instance Method Details

#chmod(mode, opts = {}) ⇒ Object

options: :noop, :verbose



18
19
20
# File 'lib/fun_with/files/file_permission_methods.rb', line 18

def chmod( mode, opts = {} )
  FileUtils.chmod( mode, self, ** Utils::Opts.narrow_file_utils_options( opts, :chmod ) )
end

#chown(user, opts = {}) ⇒ Object

options: :noop, :verbose



23
24
25
# File 'lib/fun_with/files/file_permission_methods.rb', line 23

def chown( user, opts = {} )
  FileUtils.chown( user, self, ** Utils::Opts.narrow_file_utils_options( opts, :chown ) )
end

#executable?(&block) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/fun_with/files/file_permission_methods.rb', line 13

def executable?( &block )
  _yield_self_on_success( File.executable?( self ), &block )
end

#ownerObject



27
28
29
30
# File 'lib/fun_with/files/file_permission_methods.rb', line 27

def owner
  uid = File.stat( self ).uid
  Etc.getpwuid( uid ).name
end

#readable?(&block) ⇒ Boolean

Returns:

  • (Boolean)


5
6
7
# File 'lib/fun_with/files/file_permission_methods.rb', line 5

def readable?( &block )
  _yield_self_on_success( File.readable?( self ), &block )
end

#writable?(&block) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/fun_with/files/file_permission_methods.rb', line 9

def writable?( &block )
  _yield_self_on_success( File.writable?( self ), &block )
end