Created
November 25, 2010 10:24
-
-
Save destroytoday/715174 to your computer and use it in GitHub Desktop.
Prints the number of files and lines of code inside the given path with the given extension
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
require 'find' | |
if ARGV.length != 2 | |
raise ArgumentError.new('Two arguments are required: path, extension') | |
end | |
path = ARGV[0] | |
extension = ARGV[1] | |
numFiles = 0 | |
numLines = 0 | |
Find.find(path) do |f| | |
if File.file?(f) && File.fnmatch('*.' + extension, f) | |
numFiles += 1 | |
numLines += File.new(f, 'r').readlines.length | |
end | |
end | |
puts ".#{extension} - #{numFiles} files / #{numLines} lines of code" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment