Created
May 31, 2012 15:10
-
-
Save apeckham/2844037 to your computer and use it in GitHub Desktop.
hash the contents of the public directory, inspired by http://grosser.it/2010/01/12/checksum-for-a-whole-folder-in-ruby/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def self.commit_hash | |
| @commit_hash ||= begin | |
| files = Dir["public/**/*"].select { |f| File.file?(f) }.sort | |
| contents = files.map { |f| File.read(f) }.join | |
| hash = Digest::MD5.hexdigest(contents)[0..6] | |
| "rel-#{hash}" | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment