Sha256: 0bdb08df44e79598f62b4c55f125c8b4f5fd591cd9cbc6de6451f33d315ef436

Contents?: true

Size: 859 Bytes

Versions: 30

Compression:

Stored size: 859 Bytes

Contents

#
# converted from the gitrb project
#
# authors:
#    Matthias Lederhofer <matled@gmx.net>
#    Simon 'corecode' Schubert <corecode@fs.ei.tum.de>
#
# provides native ruby access to git objects and pack files
#

require 'digest/sha1'

module Grit
  module GitRuby
    module Internal
      OBJ_NONE = 0
      OBJ_COMMIT = 1
      OBJ_TREE = 2
      OBJ_BLOB = 3
      OBJ_TAG = 4

      OBJ_TYPES = [nil, :commit, :tree, :blob, :tag].freeze

      class RawObject
        attr_accessor :type, :content
        def initialize(type, content)
          @type = type
          @content = content
        end

        def sha1
          Digest::SHA1.digest("%s %d\0" % [@type, @content.length] + @content)
        end

        def to_hash
          {
            :type => @type,
            :content => @content
          }
        end
      end
    end
  end
end

Version data entries

30 entries across 30 versions & 5 rubygems

Version Path
gitlab-grit-2.8.3 lib/grit/git-ruby/internal/raw_object.rb
gitlab-grit-2.8.2 lib/grit/git-ruby/internal/raw_object.rb
gitlab-grit-2.8.1 lib/grit/git-ruby/internal/raw_object.rb
gitlab-grit-2.8.0 lib/grit/git-ruby/internal/raw_object.rb
gitlab-grit-2.7.3 lib/grit/git-ruby/internal/raw_object.rb
gitlab-grit-2.6.12 lib/grit/git-ruby/internal/raw_object.rb
gitlab-grit-2.7.2 lib/grit/git-ruby/internal/raw_object.rb
gitlab-grit-2.6.11 lib/grit/git-ruby/internal/raw_object.rb
gitlab-grit-2.7.1 lib/grit/git-ruby/internal/raw_object.rb
gitlab-grit-2.6.10 lib/grit/git-ruby/internal/raw_object.rb
gitlab-grit-2.7.0 lib/grit/git-ruby/internal/raw_object.rb
gitlab-grit-2.6.9 lib/grit/git-ruby/internal/raw_object.rb
gitlab-grit-2.6.8 lib/grit/git-ruby/internal/raw_object.rb
gitlab-grit-2.6.7 lib/grit/git-ruby/internal/raw_object.rb
gitlab-grit-2.6.6 lib/grit/git-ruby/internal/raw_object.rb
gitlab-grit-2.6.5 lib/grit/git-ruby/internal/raw_object.rb
gitlab-grit-2.6.4 lib/grit/git-ruby/internal/raw_object.rb
gitlab-grit-2.6.3 lib/grit/git-ruby/internal/raw_object.rb
gitlab-grit-2.6.2 lib/grit/git-ruby/internal/raw_object.rb
gitlab-grit-2.5.2 lib/grit/git-ruby/internal/raw_object.rb