Sha256: dfc54ef421a4a9373016fa903ac7535c60b4b807f1e03b512873fa9c9d6a5dd1

Contents?: true

Size: 334 Bytes

Versions: 10

Compression:

Stored size: 334 Bytes

Contents

module Siteleaf
  module GitHash
    # equivalent of `git hash-object file.txt`
    def self.file(filename)
      ::File.open(filename, 'r') do |f|
        Digest::SHA1.hexdigest("blob #{f.size}\0#{f.read}")
      end
    end
    
    def self.string(str)
      Digest::SHA1.hexdigest("blob #{str.bytesize}\0#{str}")
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
siteleaf-2.3.0 lib/siteleaf/git_hash.rb
siteleaf-2.2.1 lib/siteleaf/git_hash.rb
siteleaf-2.2.0 lib/siteleaf/git_hash.rb
siteleaf-2.1.2 lib/siteleaf/git_hash.rb
siteleaf-2.1.1 lib/siteleaf/git_hash.rb
siteleaf-2.1.0 lib/siteleaf/git_hash.rb
siteleaf-2.0.2 lib/siteleaf/git_hash.rb
siteleaf-2.0.1 lib/siteleaf/git_hash.rb
siteleaf-2.0.0 lib/siteleaf/git_hash.rb
siteleaf-2.0.0.pre.beta9 lib/siteleaf/git_hash.rb