Skip to content

Instantly share code, notes, and snippets.

@next2you
Created February 27, 2012 08:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save next2you/1922588 to your computer and use it in GitHub Desktop.
Save next2you/1922588 to your computer and use it in GitHub Desktop.
Check all gem files if they are readable
#!/usr/bin/env ruby
require 'rubygems/format'
require 'thread'
queue = Queue.new
Dir["gems/*.gem"].sort.each do |gem|
#puts "Processing #{gem}"
queue << lambda {
begin
Gem::Format.from_file_by_path(gem)
rescue => e
puts "ERROR: #{gem}: #{e.message}"
rescue SyntaxError => e
puts "SYNTAX ERROR: #{gem}: #{e.message}"
end
}
end
puts "Processing..."
threads = []
10.times do |i|
threads << Thread.new do
queue.pop.call while true
end
end
until queue.empty? && queue.num_waiting == 10
threads.each { |t| t.join(0.1) }
end
thread.each { |t| t.kill }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment