Sha256: 3e16d8eebcdf8a1d73ad0fe11a020a8c08936230cfb130820906b3b71904754e

Contents?: true

Size: 919 Bytes

Versions: 1

Compression:

Stored size: 919 Bytes

Contents

module FunWith
  module Files
    # view and change file permissions
    module FilePermissionMethods
      def readable?( &block )
        _yield_self_on_success( File.readable?( self ), &block )
      end
      
      def writable?( &block )
        _yield_self_on_success( File.writable?( self ), &block )
      end
      
      def executable?( &block )
        _yield_self_on_success( File.executable?( self ), &block )
      end
      
      # options:  :noop, :verbose
      def chmod( mode, opts = {} )
        FileUtils.chmod( mode, self, ** Utils::Opts.narrow_file_utils_options( opts, :chmod ) )
      end 
      
      # options:  :noop, :verbose
      def chown( user, opts = {} )
        FileUtils.chown( user, self, ** Utils::Opts.narrow_file_utils_options( opts, :chown ) )
      end
      
      def owner
        uid = File.stat( self ).uid
        Etc.getpwuid( uid ).name
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fun_with_files-0.0.18 ./lib/fun_with/files/file_permission_methods.rb