Module: LabelWeaver::Util

Defined in:
lib/label_weaver/util.rb

Class Method Summary collapse

Class Method Details

.digest(file) ⇒ Object



3
4
5
6
7
8
9
10
# File 'lib/label_weaver/util.rb', line 3

def digest(file)
  if file.symlink?
    # for symlinks we just use the target path
    file.readlink
  else
    Digest::SHA1.file(file).hexdigest
  end
end

.file_exists?(file) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/label_weaver/util.rb', line 13

def file_exists?(file)
  file.symlink? || file.exist?
end

.mtime(file) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/label_weaver/util.rb', line 18

def mtime(file)
  if file.symlink? && !file.exist?
    0
  else
    file.mtime
  end
end