Created
December 26, 2010 03:08
-
-
Save addame/755184 to your computer and use it in GitHub Desktop.
This file contains 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
# a dirty method to write all installed gems in a file as commands ready ... for installation | |
# useful when upgrading (even if rvm is a killer ;-) ) | |
require "date" | |
def list_installed_gems | |
gems = `gem list` | |
all_gems = gems.chomp!.split(/\n/) | |
@f = File.open("gem_list_install_#{Date.parse(Time.now.to_s).to_s}.sh", "w") | |
# create install commande | |
all_gems.each do |gem| | |
gem =~ /(\S+)\s\((.+)\)/im | |
@gem_name = $1 | |
# save them into arrays | |
@gem_versions = $2.split(/,/) | |
# print the commands | |
@gem_versions.each do |gem_version| | |
#puts "gem install #{@gem_name} --version=#{gem_version.strip} --no-ri --no-rdoc \n" | |
@f.write("gem install #{@gem_name} --version=#{gem_version.strip} --no-ri --no-rdoc \n") | |
end | |
end | |
@f.close | |
end | |
list_installed_gems |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment