Skip to content

Instantly share code, notes, and snippets.

@thbar
Last active June 10, 2017 12:24
Show Gist options
  • Save thbar/f7194b138c004deae80eaa8b9864f796 to your computer and use it in GitHub Desktop.
Save thbar/f7194b138c004deae80eaa8b9864f796 to your computer and use it in GitHub Desktop.
A lo-tech gem auto-updated script
# Important: please make sure to still carefully read each gem changelog!
require 'yaml'
def system!(cmd)
raise "Cannot run command!!!" unless system(cmd)
end
gems = YAML.load(IO.read('outdated.yml')).fetch('gems')
gems.each do |gem|
puts "Auto-update #{gem}"
system!("bundle update #{gem}")
puts "Testing for #{gem}"
if system("git diff --exit-code Gemfile.lock")
puts "Nothing to update"
else
if system("bundle exec rspec")
puts "Tests successful - committing upgrade for #{gem}"
system!("git add Gemfile.lock")
system!("git commit -m \"Update #{gem}\"")
else
puts "Tests failed!"
system!("git checkout Gemfile.lock")
end
end
end
# fill this with bundle outdated or similar
gems:
- httparty
- recurly
- awesome_print
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment