Class: Grit::GitRuby::Tree
- Defined in:
- lib/grit/git-ruby/git_object.rb
Instance Attribute Summary collapse
-
#entry ⇒ Object
Returns the value of attribute entry.
Attributes inherited from GitObject
Class Method Summary collapse
Instance Method Summary collapse
- #actual_raw ⇒ Object
-
#initialize(entries = [], repository = nil) ⇒ Tree
constructor
A new instance of Tree.
- #raw_content ⇒ Object
- #type ⇒ Object
Methods inherited from GitObject
Constructor Details
#initialize(entries = [], repository = nil) ⇒ Tree
Returns a new instance of Tree.
219 220 221 222 |
# File 'lib/grit/git-ruby/git_object.rb', line 219 def initialize(entries=[], repository = nil) @entry = entries @repository = repository end |
Instance Attribute Details
#entry ⇒ Object
Returns the value of attribute entry.
202 203 204 |
# File 'lib/grit/git-ruby/git_object.rb', line 202 def entry @entry end |
Class Method Details
.from_raw(rawobject, repository = nil) ⇒ Object
204 205 206 207 208 209 210 211 212 213 214 215 216 217 |
# File 'lib/grit/git-ruby/git_object.rb', line 204 def self.from_raw(rawobject, repository=nil) raw = StringIO.new(rawobject.content) entries = [] while !raw.eof? mode = Grit::GitRuby.read_bytes_until(raw, ' ') file_name = Grit::GitRuby.read_bytes_until(raw, "\0") raw_sha = raw.read(20) sha = raw_sha.unpack("H*").first entries << DirectoryEntry.new(mode, file_name, sha) end new(entries, repository) end |
Instance Method Details
#actual_raw ⇒ Object
234 235 236 |
# File 'lib/grit/git-ruby/git_object.rb', line 234 def actual_raw #@entry.collect { |e| e.raw.join(' '), e.name].join("\t") }.join("\n") end |
#raw_content ⇒ Object
228 229 230 231 232 |
# File 'lib/grit/git-ruby/git_object.rb', line 228 def raw_content # TODO: sort correctly #@entry.sort { |a,b| a.name <=> b.name }. @entry.collect { |e| [[e.format_mode, e.format_type, e.sha1].join(' '), e.safe_name].join("\t") }.join("\n") end |
#type ⇒ Object
224 225 226 |
# File 'lib/grit/git-ruby/git_object.rb', line 224 def type :tree end |