Sha256: d3f25d726d7f866b3a6d9e1fd1cc27769246ede226070907ae194333a39d4830

Contents?: true

Size: 1.06 KB

Versions: 40

Compression:

Stored size: 1.06 KB

Contents

require 'etc'

module Test
  module Ox

    class File
      attr_accessor :name, :ctime, :mtime, :size, :owner, :group, :permissions

      def initialize(filename)
        @name = ::File.basename(filename)
        stat = ::File.stat(filename)
        @ctime = stat.ctime
        @mtime = stat.mtime
        @size = stat.size
        @owner = Etc.getpwuid(stat.uid).name
        @group = Etc.getgrgid(stat.gid).name
        @permissions = {
          :user => [(0 != (stat.mode & 0x0100)) ? 'r' : '-',
                    (0 != (stat.mode & 0x0080)) ? 'w' : '-',
                    (0 != (stat.mode & 0x0040)) ? 'x' : '-'].join(''),
          :group => [(0 != (stat.mode & 0x0020)) ? 'r' : '-',
                     (0 != (stat.mode & 0x0010)) ? 'w' : '-',
                     (0 != (stat.mode & 0x0008)) ? 'x' : '-'].join(''),
          :other => [(0 != (stat.mode & 0x0004)) ? 'r' : '-',
                     (0 != (stat.mode & 0x0002)) ? 'w' : '-',
                     (0 != (stat.mode & 0x0001)) ? 'x' : '-'].join('')
        }
      end

    end # File
  end # Ox
end # Test

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
ox-1.5.4 test/ox/file.rb
ox-1.5.3 test/ox/file.rb
ox-1.5.2 test/ox/file.rb
ox-1.5.1 test/ox/file.rb
ox-1.5.0 test/ox/file.rb
ox-1.4.6 test/ox/file.rb
ox-1.4.5 test/ox/file.rb
ox-1.4.4 test/ox/file.rb
ox-1.4.3 test/ox/file.rb
ox-1.4.2 test/ox/file.rb
ox-1.4.1 test/ox/file.rb
ox-1.4.0 test/ox/file.rb
ox-1.3.5 test/ox/file.rb
ox-1.3.4 test/ox/file.rb
ox-1.3.3 test/ox/file.rb
ox-1.3.2 test/ox/file.rb
ox-1.3.1 test/ox/file.rb
ox-1.3.0 test/ox/file.rb
ox-1.2.15 test/ox/file.rb
ox-1.2.14 test/ox/file.rb