Last active
June 10, 2017 12:24
-
-
Save thbar/f7194b138c004deae80eaa8b9864f796 to your computer and use it in GitHub Desktop.
A lo-tech gem auto-updated script
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
# 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 |
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
# 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