Created
January 8, 2011 18:38
-
-
Save Stray/771048 to your computer and use it in GitHub Desktop.
Counts files, lines, words in a folder (by file extension) and then gives you a pure typing time analysis
This file contains 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 | |
lines = 0 | |
words = 0 | |
chars = 0 | |
results = [] | |
Find.find(path) do |f| | |
if File.file?(f) && File.fnmatch('*.' + extension, f) | |
File.new(f, "r").each { |line| results << line } | |
puts "#{f} has" | |
lines += results.size | |
results.each do |line| | |
chars += line.length | |
words += line.split.length | |
end | |
results = [] | |
numFiles += 1 | |
end | |
end | |
puts ".#{extension} - #{numFiles} files / #{lines} lines of code / #{words} words of code" | |
minutes = words/80 | |
hours = minutes/60 | |
days = hours/8 | |
puts "Typing this project should have taken #{minutes} minutes, which is #{hours} hours or #{days} days." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Run this in your command line like