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

base class for all git objects (blob, tree, commit, tag)

Methods

from_raw   new   raw_content   sha1   type  

Attributes

repository  [RW] 

Public Class methods

[Source]

    # File lib/grit/git-ruby/git_object.rb, line 53
53:     def GitObject.from_raw(rawobject, repository = nil)      
54:       case rawobject.type
55:       when :blob
56:         return Blob.from_raw(rawobject, repository)
57:       when :tree
58:         return Tree.from_raw(rawobject, repository)
59:       when :commit
60:         return Commit.from_raw(rawobject, repository)
61:       when :tag
62:         return Tag.from_raw(rawobject, repository)
63:       else
64:         raise RuntimeError, "got invalid object-type"
65:       end
66:     end

[Source]

    # File lib/grit/git-ruby/git_object.rb, line 68
68:     def initialize
69:       raise NotImplemented, "abstract class"
70:     end

Public Instance methods

[Source]

    # File lib/grit/git-ruby/git_object.rb, line 76
76:     def raw_content
77:       raise NotImplemented, "abstract class"
78:     end

[Source]

    # File lib/grit/git-ruby/git_object.rb, line 80
80:     def sha1
81:       Digest::SHA1.hexdigest("%s %d\0" % \
82:                              [self.type, self.raw_content.length] + \
83:                              self.raw_content)
84:     end

[Source]

    # File lib/grit/git-ruby/git_object.rb, line 72
72:     def type
73:       raise NotImplemented, "abstract class"
74:     end

[Validate]