Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/env/bin ruby
- require "fileutils"
- def process(dir)
- puts "Analyzing #{dir}"
- FileUtils.cd(dir)
- puts "Finding outdated gems"
- output = `bundle outdated --strict --only-explicit --parseable`
- output.each_line do |line|
- next if line.blank?
- gem_name, newest_version, installed_version = parse_outdated_line(line)
- next if gem_name.nil?
- puts "Updating gem #{gem_name} to #{newest_version} from #{installed_version}"
- upgrade_gem(gem_name)
- end
- end
- def upgrade_gem(gem_name)
- `git checkout master`
- `git checkout -b update-gem-#{gem_name}`
- `bundle update #{gem_name}`
- `git add Gemfile.lock`
- `git commit -m 'Update gem #{gem_name}'`
- `git push`
- `hub pull-request -m 'Update gem #{gem_name}'`
- end
- def parse_outdated_line(line)
- /(.+) \(newest (.+), installed (.+)\)/.match(line)&.captures
- end
- process("/Users/gshaw/Sites/chitchats")
Add Comment
Please, Sign In to add comment