Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.