Created
February 21, 2013 14:59
-
-
Save tcannonfodder/5005242 to your computer and use it in GitHub Desktop.
Meant to be used with Markdown or other plaintext files. Looks for your estimated hours for a project, written in the syntax: [X hours]. Examples: [1 hour] , [10 hours], [10.5 hours], [.5 hours], [0.5 hours] Note that it doesn't work for estimations on the same line. I write my spec sheets where 1 bullet point has 1 estimation.
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
# Looks at the text file provided and uses my format of spec sheet hours to calculate the total hours of the project. | |
raise "Must provide Source File!" if ARGV.size < 1 | |
total_hours = 0 | |
spec_sheet = File.open(ARGV[0]) | |
spec_sheet.each{ |line| | |
specced_hours = /\[[^0-9.]*(?<hours>\d*\.\d+|[^\.]\d*).*\]/.match(line) | |
unless specced_hours.nil? | |
specced_hours = specced_hours[:hours].to_f | |
total_hours += specced_hours | |
end | |
} | |
puts "#{total_hours} hours specced" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment