Created
February 27, 2012 08:33
-
-
Save next2you/1922588 to your computer and use it in GitHub Desktop.
Check all gem files if they are readable
This file contains 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 | |
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