Created
November 23, 2011 04:04
-
-
Save ootoovak/1387856 to your computer and use it in GitHub Desktop.
Place in your a directory with Bundler projects and run to create a leaderboard of your Gems.
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/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." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment