Skip to content

Instantly share code, notes, and snippets.

@j05h
Created April 20, 2011 19:13
Show Gist options
  • Save j05h/932391 to your computer and use it in GitHub Desktop.
Save j05h/932391 to your computer and use it in GitHub Desktop.
Checks your Gemfile for public gems on rubygems.org
#!/usr/bin/env ruby
# This class will check search rubygems.org for all gems in a given Gemfile.
# If a given gem is not available on rubygems.org, it will tell you such.
class VerifyGems
def initialize _file, _source
@file = _file || 'Gemfile'
@source = _source || 'http://rubygems.org'
@gems = []
@verbose = false
unless File.exists?(@file)
puts "Please supply a Gemfile to evaluate."
exit
end
end
def gem name, version = nil, options = {}
@gems << name
end
def group *args; end
def source *args; end
def verbose?
@verbose
end
def verify
eval(File.new(@file).read)
regex = @gems.map{|name| "^#{name}$"}.join("|")
query = `gem query -r -n '#{regex}' --clear-sources --source #{@source}`
@gems.each do |name|
if query.match /#{name}/
puts "Found #{name} on #{@source}" if verbose?
else
puts "#{name} is not on #{@source}"
end
end
end
end
VerifyGems.new(ARGV.shift, ARGV.shift).verify
@j05h
Copy link
Author

j05h commented Apr 20, 2011

may make this a gem plugin. Its useful when you have your own gemserver and want to know which ones are not publicly available on the main gemserver.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment