Place in your a directory with Bundler projects and run to create a leaderboard of your Gems.
#!/usr/bin/ruby -w
puts "Counting your gems ..."
gems = {}
project_folders = Dir.entries(".").select{ |d| d !~ /^\..*/ && !File.file?(d) }
project_folders.each do |folder|
Dir.chdir(folder) do
if File.exists?('Gemfile') && File.file?('Gemfile')
File.open('Gemfile', 'r').each_line do |line|
if line =~ /^[^#y]*gem.*/
line =~ /^.*gem[^\"\']+(\"|\')([^\"\']+).*/
gems[$2] = 0 unless gems[$2]
gems[$2] += 1
end
end
end
end
end
counted_gems = File.new("counted_gems.txt", "w")
gems.sort{ |a,b| b[1] <=> a[1] }.each{ |k,v| counted_gems.puts "#{k}: (#{v})" if v > 1 }
puts "Done counting."