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
Import Your Installed Gems To Your Ruby Enterprise Ed. Gems
// mirrors your Ruby Enterprise gem list to your regular Ruby installed gems
#!/opt/local/bin/ruby
# The command to run for your vanila Ruby 'gem' command
OLD_GEM='gem'
# The command to run for REE's 'gem' command
NEW_GEM='RUBYOPT="" /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




