Skip to content

Instantly share code, notes, and snippets.

@patrickgombert
Last active August 29, 2015 13:57
Show Gist options
  • Save patrickgombert/9443008 to your computer and use it in GitHub Desktop.
Save patrickgombert/9443008 to your computer and use it in GitHub Desktop.
cat Gemfile.lock | sed -n '/specs\:/,/^$/p' | sed 1d | awk '{print $1}' | sort | uniq | xargs gem contents | wc -l
GFILE = "Gemfile.lock" #\
list = File.read(GFILE) #\
#\
gems = [] #> cat Gemfile.lock |
#/
list.each_line do |line| #/
line = line.strip #/
break if line.include?("PLATFORMS") #\
next if line.include?("GEM") #\
next if line.include?("remote:") #\
next if line.include?("specs:") #> sed -n '/specs\:/,/^$/p' |
next if line.empty? #/ sed 1d |
gems.push(line.split(' ').first) #/ awk'{print $1}' |
end #/
total = 0 #\
gems.uniq! #/ sort | uniq |
gems.each do |gem| #\
puts "Processing #{gem}" #\
contents = `gem contents #{gem}`.split #> xargs gem contents |
local = 0 #/
contents.each do |file| #/
output = `wc -l #{file}` #\
amount = output.strip.split(' ').first.to_i #\
local += amount #\
end #> wc -l
puts " LOC: #{local}" #/
total += local #/
end #/
#/
puts "Total Lines: #{total}" #/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment