Skip to content

Instantly share code, notes, and snippets.

@raggi
Created February 21, 2011 00:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raggi/836462 to your computer and use it in GitHub Desktop.
Save raggi/836462 to your computer and use it in GitHub Desktop.
Optimize your installed gemspecs for rubygems 1.6, can save 4+mb of ram with 500+ gems installed.
require 'rubygems'
globs = Gem.path.map { |path| File.join(path, 'specifications', '*.gemspec') }
updated = 0
Dir["{#{globs.join(',')}}"].each do |f|
spec = Gem::Specification.load(f)
open(f, 'w') do |io|
io.write spec.to_ruby_for_cache
end
updated += 1
end
puts "Updated #{updated} gemspecs"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment