Guest User

Untitled

a guest
Dec 14th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. #!/env/bin ruby
  2.  
  3. require "fileutils"
  4.  
  5. def process(dir)
  6.  
  7. puts "Analyzing #{dir}"
  8. FileUtils.cd(dir)
  9.  
  10. puts "Finding outdated gems"
  11. output = `bundle outdated --strict --only-explicit --parseable`
  12.  
  13. output.each_line do |line|
  14. next if line.blank?
  15.  
  16. gem_name, newest_version, installed_version = parse_outdated_line(line)
  17. next if gem_name.nil?
  18.  
  19. puts "Updating gem #{gem_name} to #{newest_version} from #{installed_version}"
  20. upgrade_gem(gem_name)
  21. end
  22. end
  23.  
  24. def upgrade_gem(gem_name)
  25. `git checkout master`
  26. `git checkout -b update-gem-#{gem_name}`
  27. `bundle update #{gem_name}`
  28. `git add Gemfile.lock`
  29. `git commit -m 'Update gem #{gem_name}'`
  30. `git push`
  31. `hub pull-request -m 'Update gem #{gem_name}'`
  32. end
  33.  
  34. def parse_outdated_line(line)
  35. /(.+) \(newest (.+), installed (.+)\)/.match(line)&.captures
  36. end
  37.  
  38. process("/Users/gshaw/Sites/chitchats")
Add Comment
Please, Sign In to add comment