rake stats for engines

This commit is contained in:
Andriy Tyurnikov 2014-05-23 23:28:06 +03:00
parent a6f55fe257
commit b71f5f4f55
2 changed files with 24 additions and 19 deletions

@ -19,6 +19,10 @@ APP_RAKEFILE = File.expand_path("../<%= dummy_path -%>/Rakefile", __FILE__)
load 'rails/tasks/engine.rake' load 'rails/tasks/engine.rake'
<% end %> <% end %>
<% if engine? -%>
load 'rails/tasks/statistics.rake'
<% end %>
<% unless options[:skip_gemspec] -%> <% unless options[:skip_gemspec] -%>
Bundler::GemHelper.install_tasks Bundler::GemHelper.install_tasks

@ -1,22 +1,23 @@
STATS_DIRECTORIES = [ desc "Report code statistics (KLOCs, etc) from the application or engine"
%w(Controllers app/controllers),
%w(Helpers app/helpers),
%w(Models app/models),
%w(Mailers app/mailers),
%w(Javascripts app/assets/javascripts),
%w(Libraries lib/),
%w(APIs app/apis),
%w(Controller\ tests test/controllers),
%w(Helper\ tests test/helpers),
%w(Model\ tests test/models),
%w(Mailer\ tests test/mailers),
%w(Integration\ tests test/integration),
%w(Functional\ tests\ (old) test/functional),
%w(Unit\ tests \ (old) test/unit)
].collect { |name, dir| [ name, "#{Rails.root}/#{dir}" ] }.select { |name, dir| File.directory?(dir) }
desc "Report code statistics (KLOCs, etc) from the application"
task :stats do task :stats do
require 'rails/code_statistics' require 'rails/code_statistics'
STATS_DIRECTORIES = [
%w(Controllers app/controllers),
%w(Helpers app/helpers),
%w(Models app/models),
%w(Mailers app/mailers),
%w(Javascripts app/assets/javascripts),
%w(Libraries lib/),
%w(APIs app/apis),
%w(Controller\ tests test/controllers),
%w(Helper\ tests test/helpers),
%w(Model\ tests test/models),
%w(Mailer\ tests test/mailers),
%w(Integration\ tests test/integration),
%w(Functional\ tests\ (old) test/functional),
%w(Unit\ tests \ (old) test/unit)
].collect { |name, dir| [ name, "#{defined?(ENGINE_PATH)? ENGINE_PATH : Rails.root}/#{dir}" ] }.select { |name, dir| File.directory?(dir) }
CodeStatistics.new(*STATS_DIRECTORIES).to_s CodeStatistics.new(*STATS_DIRECTORIES).to_s
end end