Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Stupid rake task to randomly pick one outdated gem
require 'open3'
require 'rainbow'
desc "Upgrade gems"
namespace :upgrade do
desc "Find a random gem to update"
task :bingo => :environment do
cmd = 'bundle outdated'
stdout, stderr, status = Open3.capture3(cmd)
outdated_gem = stdout.lines.grep(/ \* .*/).sample
gemname = outdated_gem.match(/ \* (\w*).*/)[1]
puts Rainbow("Selecting a dirty old gem for you to polish...")
puts Rainbow("1. Create a branch called upgrade-#{gemname}")
puts Rainbow("2. Find the Github page for #{gemname} and read the CHANGELOG")
puts Rainbow('3. Update the gem to the highest version possible without upgrading Ruby or Rails')
puts Rainbow(" bundle update #{gemname}").green
puts Rainbow('4. Update any required gems')
puts Rainbow('5. Merge into staging once the specs pass')
puts Rainbow("6. If, at #{(Time.now + 30.minutes).strftime('%H %M')} the specs still aren\'t passing, write it up in Trello").yellow
puts Rainbow('=================================================').red
print Rainbow(outdated_gem.to_s).red
puts Rainbow('=================================================').red
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment