Skip to content

Instantly share code, notes, and snippets.

@mark-d-holmberg
Created May 4, 2017 18:11
Show Gist options
  • Save mark-d-holmberg/2da7283eb106f89b8d7f698815a952bc to your computer and use it in GitHub Desktop.
Save mark-d-holmberg/2da7283eb106f89b8d7f698815a952bc to your computer and use it in GitHub Desktop.
MD5Sum a Directory in Ruby.
require 'digest'
files = Dir["#{Dir.pwd}/db-migrate/**/*.rb"]
sorted = files.map { |file| Digest::MD5.file(file).hexdigest }.sort
content = ""
sorted.each { |k| content << "#{k}\n" }
Digest::MD5.hexdigest(content)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment