Created
February 19, 2011 01:01
-
-
Save f440/834704 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env ruby | |
#-*- coding: utf-8 -*- | |
# | |
# unify dupulicated gem files. | |
# | |
# This work is in the public domain. | |
# | |
require 'digest/md5' | |
h = {} | |
Dir.glob("#{ENV['HOME']}/.rvm/gems/**/*.gem").each do |file| | |
md5 = Digest::MD5.file(file).to_s | |
if h[md5] | |
unless FileTest.identical? h[md5], file | |
File.unlink file | |
puts "link #{h[md5]} => #{file}" | |
File.link h[md5], file | |
end | |
else | |
h[md5] = file | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment