Created
November 6, 2008 12:31
-
-
Save joerichsen/22577 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/ruby | |
# Adapted version of http://griffin.oobleyboo.com/archive/ruby-enterprise-edition-gem-install-script/ | |
# The command to run for your vanila Ruby 'gem' command | |
OLD_GEM='gem' | |
# The command to run for REE's 'gem' command | |
NEW_GEM='/opt/ruby-enterprise-1.8.6-20080810/bin/ruby /opt/ruby-enterprise-1.8.6-20080810/bin/gem' | |
output=`#{OLD_GEM} list` | |
new_list=`#{NEW_GEM} list` | |
output.each do |line| | |
# Skip lines that don't look like a gem version | |
matches=line.match(/([A-Z].+) \(([0-9\., ]+)\)/i) | |
if matches then | |
gem_name=matches[1] | |
versions=matches[2] | |
versions.split(', ').each do |ver| | |
cmd="#{NEW_GEM} install #{gem_name} -v #{ver} --no-rdoc --no-ri --backtrace -y" | |
# See if this gem is already installed | |
if new_list =~ /#{gem_name} \(.*#{ver}.*\)/i then | |
puts "#{gem_name} #{ver} is already installed. Skipping" | |
else | |
puts cmd | |
system(cmd) | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment