Module: Nanoc3::PathnameExtensions
- Included in:
- Pathname
- Defined in:
- lib/nanoc3/base/core_ext/pathname.rb
Instance Method Summary collapse
-
#checksum ⇒ String
private
Calculates the checksum for the file referenced to by this pathname.
Instance Method Details
#checksum ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Calculates the checksum for the file referenced to by this pathname. Any change to the file contents will result in a different checksum.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/nanoc3/base/core_ext/pathname.rb', line 11 def checksum digest = Digest::SHA1.new File.open(self.to_s, 'r') do |io| until io.eof data = io.read(2**10) digest.update(data) end end digest.hexdigest end |