Module: Siteleaf::GitHash
- Defined in:
- lib/siteleaf/git_hash.rb
Class Method Summary collapse
-
.file(filename) ⇒ Object
equivalent of ‘git hash-object file.txt`.
- .string(str) ⇒ Object
Class Method Details
.file(filename) ⇒ Object
equivalent of ‘git hash-object file.txt`
4 5 6 7 8 |
# File 'lib/siteleaf/git_hash.rb', line 4 def self.file(filename) ::File.open(filename, 'r') do |f| Digest::SHA1.hexdigest("blob #{f.size}\0#{f.read}") end end |
.string(str) ⇒ Object
10 11 12 |
# File 'lib/siteleaf/git_hash.rb', line 10 def self.string(str) Digest::SHA1.hexdigest("blob #{str.bytesize}\0#{str}") end |