Created
February 3, 2009 20:56
-
-
Save semanticart/57746 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
# generate the commands to install all currently missing versions from the output of `gem list` from | |
# another box to your local machine. `gem list` should be of format | |
# actionmailer (2.2.2, 2.1.0) | |
# actionpack (2.2.2, 2.1.0) | |
# ... | |
# will_paginate (2.2.2) | |
# ZenTest (3.9.2) | |
# | |
# usage: ruby install_gems.rb /path/to/your/gem/list/output.txt | |
require 'rubygems' | |
require 'rubygems/command' | |
require 'rubygems/commands/query_command' | |
class Gem::Commands::QueryCommand | |
public :installed? | |
end | |
file = ARGV[0] | |
raise "Could not read from #{file}" unless File.exist?(file) | |
File.readlines(file).each do |line| | |
name, versions = line.strip.split(/ /, 2) | |
versions.gsub(/[\(\)]/, '').split(', ').map do |version| | |
unless Gem::Commands::QueryCommand.new.installed?(name, version) | |
puts "sudo gem install #{name} -v #{version}" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment