Class: Floccus::Filename

Inherits:
Object
  • Object
show all
Defined in:
lib/floccus/filename.rb

Class Method Summary collapse

Class Method Details

.generate(filename) ⇒ Object

Generate a hashed filename based on the contents

Returns the hash followed by the filename



6
7
8
9
10
11
12
# File 'lib/floccus/filename.rb', line 6

def self.generate(filename)
  file_path = File.expand_path(filename)
  contents = File.read(file_path)
  hash = Digest::MD5.hexdigest(contents)
     
  "#{hash}-#{filename}"
end