public
Last active

Check for uninstalled gem dependencies.

  • Download Gist
gem-depcheck
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
#!/usr/bin/ruby
require 'rubygems'
installed_gems = Gem::Dependency.new '', Gem::Requirement.default
missing = []
# mind the short-hand, looping over installed gem specs
specs = Gem.source_index.search installed_gems
specs.each do |spec|
gem = Gem::Dependency.new spec.name, spec.version
# looping over gem dependencies
specs = Gem.source_index.search gem
deps = specs.first.runtime_dependencies
deps.each do |dep|
# check if the dependency is missing
specs = Gem.source_index.search dep
if specs === [] then
missing.push dep
end
end
end
print missing.sort.uniq.collect{|spec| "#{spec}\n"}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.