DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Remove Older Gem Versions

06.18.2010
| 2678 views |
  • submit to reddit
        // description of your code here
This code removes all but the most recent version of each ruby gem in your system.

EOL_SEPARATOR = "\n"
gems = `gem list`.split(EOL_SEPARATOR)
gems.each do |g|    
  gem_name = g.split("(").first
  cmd = "gem cleanup #{gem_name}"
  system(cmd)
end
    

Comments

Snippets Manager replied on Tue, 2007/06/05 - 11:43am

You could also simply use gem cleanup It cleans up every gem.