Skip to content

Instantly share code, notes, and snippets.

@ovidiubite
Last active January 8, 2021 16:25
Show Gist options
  • Save ovidiubite/fef079db62120fbcccf9508e0820aad3 to your computer and use it in GitHub Desktop.
Save ovidiubite/fef079db62120fbcccf9508e0820aad3 to your computer and use it in GitHub Desktop.
rubocop_installer.rb
require 'bundler'
gems = Bundler::LockfileParser.new(Bundler.read_file("Gemfile.lock"))
rubocop_dependencies = gems.specs.map{|e| [e.name,e.version.to_s]}.select{|e| e.first.include?('rubocop') }
rubocop_dependencies.each do |gem|
gem_ver = "#{gem[0]} -v #{gem[1]}"
puts "executing: #{gem_ver}"
abort("Failed to install: #{gem_ver}") unless system("gem install #{gem_ver}")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment