have the pure ruby bindings working to some degree
[rubygit.git] / lib / git / raw / internal / object.rb
blob7f956851fe3da19b02e2903acb163344daabbad2
1 require 'digest/sha1'
3 module Git 
4   module Raw 
5     module Internal
6       OBJ_NONE = 0
7       OBJ_COMMIT = 1
8       OBJ_TREE = 2
9       OBJ_BLOB = 3
10       OBJ_TAG = 4
12       OBJ_TYPES = [nil, :commit, :tree, :blob, :tag].freeze
14       class RawObject
15         attr_accessor :type, :content
16         def initialize(type, content)
17           @type = type
18           @content = content
19         end
21         def sha1
22           Digest::SHA1.digest("%s %d\0" % [@type, @content.length] + @content)
23         end
24       end
25     end 
26   end
27 end