Skip to content

Instantly share code, notes, and snippets.

@zchee zchee/gem-reset forked from nixpulvis/gem-reset
Last active Dec 13, 2017

Embed
What would you like to do?
#!/usr/bin/env ruby
# Remove all gems EXCEPT defaults :)
`gem list -d|ruby -pe 'gsub(/bundler|nokogiri/,"")'`.split(/\n\n^(?=\w)/).each do |data|
match = data.match(/(?<name>([^\s]+)) \((?<versions>.*)\)/)
name = match[:name]
versions = match[:versions].split(', ')
if match = data.match(/^.*\(([\d\.]*),? ?default\): .*$/)
next if match[1].empty? # it's the only version if this match is empty
versions.delete(match[1] || versions[0])
end
versions.each { |v| system "gem uninstall -Ix #{name} -v #{v}" }
end
#!/usr/bin/env ruby
# Remove all gems EXCEPT defaults :)
`gem list -d|ruby -pe 'gsub(/bundler|nokogiri|tmuxinator|erubis|thor|sass|rainbow|scss-lint|sheet/,"")'`.split(/\n\n^(?=\w)/).each do |data|
match = data.match(/(?<name>([^\s]+)) \((?<versions>.*)\)/)
name = match[:name]
versions = match[:versions].split(', ')
if match = data.match(/^.*\(([\d\.]*),? ?default\): .*$/)
next if match[1].empty? # it's the only version if this match is empty
versions.delete(match[1] || versions[0])
end
versions.each { |v| system "gem uninstall -Ix #{name} -v #{v}" }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.