Class: Grit::GitRuby::GitObject
- Inherits:
-
Object
- Object
- Grit::GitRuby::GitObject
- Defined in:
- lib/grit/git-ruby/git_object.rb
Overview
base class for all git objects (blob, tree, commit, tag)
Instance Attribute Summary (collapse)
-
- (Object) repository
Returns the value of attribute repository.
-
- (Object) sha
Returns the value of attribute sha.
Class Method Summary (collapse)
Instance Method Summary (collapse)
-
- (GitObject) initialize
constructor
A new instance of GitObject.
- - (Object) raw_content
- - (Object) sha1
- - (Object) type
Constructor Details
- (GitObject) initialize
A new instance of GitObject
69 70 71 |
# File 'lib/grit/git-ruby/git_object.rb', line 69 def initialize raise NotImplemented, "abstract class" end |
Instance Attribute Details
- (Object) repository
Returns the value of attribute repository
51 52 53 |
# File 'lib/grit/git-ruby/git_object.rb', line 51 def repository @repository end |
- (Object) sha
Returns the value of attribute sha
52 53 54 |
# File 'lib/grit/git-ruby/git_object.rb', line 52 def sha @sha end |
Class Method Details
+ (Object) from_raw(rawobject, repository = nil)
54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/grit/git-ruby/git_object.rb', line 54 def GitObject.from_raw(rawobject, repository = nil) case rawobject.type when :blob return Blob.from_raw(rawobject, repository) when :tree return Tree.from_raw(rawobject, repository) when :commit return Commit.from_raw(rawobject, repository) when :tag return Tag.from_raw(rawobject, repository) else raise RuntimeError, "got invalid object-type" end end |
Instance Method Details
- (Object) raw_content
77 78 79 |
# File 'lib/grit/git-ruby/git_object.rb', line 77 def raw_content raise NotImplemented, "abstract class" end |
- (Object) sha1
81 82 83 84 85 |
# File 'lib/grit/git-ruby/git_object.rb', line 81 def sha1 Digest::SHA1.hexdigest("%s %d\0" % \ [self.type, self.raw_content.length] + \ self.raw_content) end |
- (Object) type
73 74 75 |
# File 'lib/grit/git-ruby/git_object.rb', line 73 def type raise NotImplemented, "abstract class" end |