Class: Core::Watch::Strategies::Digest

Inherits:
Object
  • Object
show all
Defined in:
lib/core/watch/strategies/digest.rb

Overview

public

Identifies a path by digest or modified time (for directories).

Constant Summary collapse

BUFFER_LENGTH =
16_384

Instance Method Summary collapse

Instance Method Details

#identify(path) ⇒ Object

public


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/core/watch/strategies/digest.rb', line 17

def identify(path)
  if path.file?
    md5 = OpenSSL::Digest.new("MD5")

    path.open("rb") do |file|
      buffer = +""
      while file.read(BUFFER_LENGTH, buffer)
        md5 << buffer
      end
    end

    md5.digest
  else
    path.mtime
  end
end