Class Grit::GitRuby::DirectoryEntry
In: lib/grit/git-ruby/git_object.rb
lib/grit/git-ruby/object.rb
Parent: Object

Methods

format_mode   format_mode   format_type   format_type   new   new   raw   raw   type   type   type=   type=  

Constants

S_IFMT = 00170000
S_IFLNK = 0120000
S_IFREG = 0100000
S_IFDIR = 0040000
S_IFGITLINK = 0160000
S_IFMT = 00170000
S_IFLNK = 0120000
S_IFREG = 0100000
S_IFDIR = 0040000

Attributes

mode  [RW] 
mode  [RW] 
name  [RW] 
name  [RW] 
sha1  [RW] 
sha1  [RW] 

Public Class methods

[Source]

     # File lib/grit/git-ruby/git_object.rb, line 115
115:     def initialize(mode, filename, sha1o)
116:       @mode = 0
117:       mode.each_byte do |i|
118:         @mode = (@mode << 3) | (i-'0'.getord(0))
119:       end
120:       @name = filename
121:       @sha1 = sha1o
122:       if ![S_IFLNK, S_IFDIR, S_IFREG, S_IFGITLINK].include?(@mode & S_IFMT)
123:         raise RuntimeError, "unknown type for directory entry"
124:       end
125:     end

[Source]

     # File lib/grit/git-ruby/object.rb, line 105
105:     def initialize(mode, filename, sha1o)
106:       @mode = 0
107:       mode.each_byte do |i|
108:         @mode = (@mode << 3) | (i-'0'[0])
109:       end
110:       @name = filename
111:       @sha1 = sha1o
112:       if ![S_IFLNK, S_IFDIR, S_IFREG].include?(@mode & S_IFMT)
113:         raise RuntimeError, "unknown type for directory entry"
114:       end
115:     end

Public Instance methods

[Source]

     # File lib/grit/git-ruby/git_object.rb, line 170
170:     def format_mode
171:       "%06o" % @mode
172:     end

[Source]

     # File lib/grit/git-ruby/object.rb, line 154
154:     def format_mode
155:       "%06o" % @mode
156:     end

[Source]

     # File lib/grit/git-ruby/git_object.rb, line 157
157:     def format_type
158:       case type
159:       when :link
160:         'link'
161:       when :directory
162:         'tree'
163:       when :file
164:         'blob'
165:       when :submodule
166:         'commit'
167:       end
168:     end

[Source]

     # File lib/grit/git-ruby/object.rb, line 143
143:     def format_type
144:       case type
145:       when :link
146:         'link'
147:       when :directory
148:         'tree'
149:       when :file
150:         'blob'
151:       end
152:     end

[Source]

     # File lib/grit/git-ruby/git_object.rb, line 174
174:     def raw
175:       "%o %s\0%s" % [@mode, @name, [@sha1].pack("H*")]
176:     end

[Source]

     # File lib/grit/git-ruby/object.rb, line 158
158:     def raw
159:       "%o %s\0%s" % [@mode, @name, [@sha1].pack("H*")]
160:     end

[Source]

     # File lib/grit/git-ruby/git_object.rb, line 127
127:     def type
128:       case @mode & S_IFMT
129:       when S_IFGITLINK
130:         @type = :submodule
131:       when S_IFLNK
132:         @type = :link
133:       when S_IFDIR
134:         @type = :directory
135:       when S_IFREG
136:         @type = :file
137:       else
138:         raise RuntimeError, "unknown type for directory entry"
139:       end
140:     end

[Source]

     # File lib/grit/git-ruby/object.rb, line 117
117:     def type
118:       case @mode & S_IFMT
119:       when S_IFLNK
120:         @type = :link
121:       when S_IFDIR
122:         @type = :directory
123:       when S_IFREG
124:         @type = :file
125:       else
126:         raise RuntimeError, "unknown type for directory entry"
127:       end
128:     end

[Source]

     # File lib/grit/git-ruby/object.rb, line 130
130:     def type=(type)
131:       case @type
132:       when :link
133:         @mode = (@mode & ~S_IFMT) | S_IFLNK
134:       when :directory
135:         @mode = (@mode & ~S_IFMT) | S_IFDIR
136:       when :file
137:         @mode = (@mode & ~S_IFMT) | S_IFREG
138:       else
139:         raise RuntimeError, "invalid type"
140:       end
141:     end

[Source]

     # File lib/grit/git-ruby/git_object.rb, line 142
142:     def type=(type)
143:       case @type
144:       when :link
145:         @mode = (@mode & ~S_IFMT) | S_IFLNK
146:       when :directory
147:         @mode = (@mode & ~S_IFMT) | S_IFDIR
148:       when :file
149:         @mode = (@mode & ~S_IFMT) | S_IFREG
150:       when :submodule
151:         @mode = (@mode & ~S_IFMT) | S_IFGITLINK
152:       else
153:         raise RuntimeError, "invalid type"
154:       end
155:     end

[Validate]