Class: JsDuck::Util::MD5

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/jsduck/util/md5.rb

Overview

Helper to rename files so that the MD5 hash of their contents is placed into their name.

Instance Method Summary collapse

Methods included from Singleton

included

Instance Method Details

#rename(fname) ⇒ Object

Calculates MD5 hash of a file and renames the file to contain the hash inside the filename. Returns the new name of the file.



14
15
16
17
18
19
# File 'lib/jsduck/util/md5.rb', line 14

def rename(fname)
  hash = Digest::MD5.file(fname).hexdigest
  hashed_name = inject_hash_to_filename(fname, hash)
  File.rename(fname, hashed_name)
  return hashed_name
end