Created
April 20, 2011 19:13
-
-
Save j05h/932391 to your computer and use it in GitHub Desktop.
Checks your Gemfile for public gems on rubygems.org
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.