Module: FunWith::Files::FilePermissionMethods
- Defined in:
- lib/fun_with/files/file_permission_methods.rb
Overview
view and change file permissions
Instance Method Summary collapse
-
#chmod(mode, opts = {}) ⇒ Object
options: :noop, :verbose.
-
#chown(user, opts = {}) ⇒ Object
options: :noop, :verbose.
- #executable?(&block) ⇒ Boolean
- #owner ⇒ Object
- #readable?(&block) ⇒ Boolean
- #writable?(&block) ⇒ Boolean
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.( 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.( opts, :chown ) ) end |
#executable?(&block) ⇒ 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 |
#owner ⇒ Object
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
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
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 |