Skip to content

Instantly share code, notes, and snippets.

@f440
Created February 19, 2011 01:01
Show Gist options
  • Save f440/834704 to your computer and use it in GitHub Desktop.
Save f440/834704 to your computer and use it in GitHub Desktop.
#!/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