Skip to content

Instantly share code, notes, and snippets.

@dgilperez
Forked from kmarsh/gist:52889
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dgilperez/b0f9b3dfe8af0b37b37b to your computer and use it in GitHub Desktop.
Save dgilperez/b0f9b3dfe8af0b37b37b to your computer and use it in GitHub Desktop.
namespace :spec do
# largely lifted from http://www.pervasivecode.com/blog/2007/06/28/hacking-rakestats-to-get-gross-loc/
task :stats_setup do
require 'code_statistics'
class CodeStatistics
alias calculate_statistics_orig calculate_statistics
def calculate_statistics
@pairs.inject({}) do |stats, pair|
if 3 == pair.size
stats[pair.first] = calculate_directory_statistics(pair[1], pair[2]); stats
else
stats[pair.first] = calculate_directory_statistics(pair.last); stats
end
end
end
end
::STATS_DIRECTORIES = []
::STATS_DIRECTORIES << ['Views', 'app/views', /\.(rhtml|erb|rb|haml)$/]
::STATS_DIRECTORIES << ['CSS', 'public', /\.(css|scss|sass)$/]
end
end
namespace :stats do
desc "Report code statistics (KLOCs, etc) for non-code like HTML and CSS from the application"
task :static => ["spec:stats_setup", "stats"]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment