Created
October 24, 2014 15:51
-
-
Save joejag/948c2f69166b04057d90 to your computer and use it in GitHub Desktop.
Count lines of code, simple
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
def count_lines(directory, extension) | |
"find #{directory} -name '*.#{extension}' | xargs wc -l | tail -n 1" | |
end | |
def count_java_project(dir) | |
cmd = count_lines(dir + "/src/main", "java") | |
`#{cmd}`.chomp.split.first | |
end | |
def count_clojure_project(dir) | |
cmd = count_lines(dir + "/src", "clj") | |
`#{cmd}`.chomp.split.first | |
end | |
def count_javascript_project(dir) | |
cmd = count_lines(dir + "/src/main/resources/assets/js/app", "js") | |
`#{cmd}`.chomp.split.first | |
end | |
directories = Dir::glob('*').select {|f| File.directory? f}.sort | |
clojure_projects = %w(smokescreen assessmentengine) | |
javascript_projects = %w(optimus) | |
directories.each do |dir| | |
if clojure_projects.include? dir | |
printf "%-30s %s\n", dir, count_clojure_project(dir) | |
elsif javascript_projects.include? dir | |
printf "%-30s %s\n", dir, count_javascript_project(dir) | |
else | |
printf "%-30s %s\n", dir, count_java_project(dir) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment