added Matthias and Simon to credits for the gitrb code
[rubygit.git] / lib / git / raw / internal / object.rb
blob172b917dbc0e06271b439b200ad63eabad19b8a5
2 # converted from the gitrb project
4 # authors: 
5 #    Matthias Lederhofer <matled@gmx.net>
6 #    Simon 'corecode' Schubert <corecode@fs.ei.tum.de>
8 # provides native ruby access to git objects and pack files
11 require 'digest/sha1'
13 module Git 
14   module Raw 
15     module Internal
16       OBJ_NONE = 0
17       OBJ_COMMIT = 1
18       OBJ_TREE = 2
19       OBJ_BLOB = 3
20       OBJ_TAG = 4
22       OBJ_TYPES = [nil, :commit, :tree, :blob, :tag].freeze
24       class RawObject
25         attr_accessor :type, :content
26         def initialize(type, content)
27           @type = type
28           @content = content
29         end
31         def sha1
32           Digest::SHA1.digest("%s %d\0" % [@type, @content.length] + @content)
33         end
34       end
35     end 
36   end
37 end