Guest User

Untitled

a guest
Apr 25th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. #! /usr/bin/ruby
  2.  
  3. # Ever update/reinstall ruby and need to bring all your old gems,
  4. # including old versions to the new environment? Just output your
  5. # gem list to gem_list.txt and run it through this script.
  6.  
  7. install_all = false
  8. File.open("gem_list.txt").each do |line|
  9. # coderay (0.8.273, 0.8.260, 0.7.4.215)
  10. match_data = /(\w+) \((.+)\)/.match(line)
  11. gem_name, versions = match_data[1], match_data[2]
  12. versions = versions.split(', ')
  13.  
  14. versions.each do |version|
  15. if !install_all
  16. puts "Install #{gem_name} (v #{version}) gem? (y/n/a)"
  17. response = gets
  18. next if response =~ /^n/i
  19. install_all = true if response =~ /^a/i
  20. end
  21.  
  22. puts "Installing #{gem_name} (v #{version})"
  23. system "sudo gem install #{gem_name} -v #{version}"
  24. end
  25. end
Add Comment
Please, Sign In to add comment