Created
January 9, 2015 19:48
-
-
Save excid3/89312203ebddc3bc9b81 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
require "open-uri" | |
RUBYGEMS_VERSIONS = { | |
"1.8" => { | |
"url" => "https://github.com/rubygems/rubygems/releases/download/v1.8.30/rubygems-update-1.8.30.gem", | |
"filename" => "rubygems-update-1.8.30.gem" | |
}, | |
"2.0" => { | |
"url" => "https://github.com/rubygems/rubygems/releases/download/v2.0.15/rubygems-update-2.0.15.gem", | |
"filename" => "rubygems-update-2.0.15.gem" | |
}, | |
"2.2" => { | |
"url" => "https://github.com/rubygems/rubygems/releases/download/v2.2.3/rubygems-update-2.2.3.gem", | |
"filename" => "rubygems-update-2.2.3.gem" | |
} | |
} | |
current_rubygems_version = `gem --version` | |
puts "You currently have Rubygems #{current_rubygems_version} installed." | |
version = current_rubygems_version[0..2] | |
url = RUBYGEMS_VERSIONS[version]["url"] | |
filename = RUBYGEMS_VERSIONS[version]["filename"] | |
puts "Downloading Rubygems update (#{filename})..." | |
open(filename, 'wb') { |file| file << open(url).read } | |
puts "Installing #{filename}..." | |
`gem install --local #{filename}` | |
puts "Updating Rubygems..." | |
`update_rubygems --no-ri --no-rdoc` | |
puts "Cleaning up..." | |
`gem uninstall rubygems-update -x` | |
puts "Done!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment