diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-05-24 15:15:53 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-05-24 15:15:53 -0300 |
commit | a9ced732ad66cba3f37101c77d0475febe8b5926 (patch) | |
tree | 61adde99550ae61a3ed3aab99c1534d8a44360c8 | |
parent | 528e59062f21023aa8aaa86d66f6a8e0b81b488a (diff) | |
parent | b71f5f4f55f50bf215a650c0555f6603a3bed84b (diff) | |
download | rails-a9ced732ad66cba3f37101c77d0475febe8b5926.tar.gz rails-a9ced732ad66cba3f37101c77d0475febe8b5926.tar.bz2 rails-a9ced732ad66cba3f37101c77d0475febe8b5926.zip |
Merge pull request #15299 from andriytyurnikov/engine_friendly_rake_stats
rake stats for engines
-rw-r--r-- | railties/lib/rails/generators/rails/plugin/templates/Rakefile | 4 | ||||
-rw-r--r-- | railties/lib/rails/tasks/statistics.rake | 39 |
2 files changed, 24 insertions, 19 deletions
diff --git a/railties/lib/rails/generators/rails/plugin/templates/Rakefile b/railties/lib/rails/generators/rails/plugin/templates/Rakefile index 0ba899176c..c338a0bdb1 100644 --- a/railties/lib/rails/generators/rails/plugin/templates/Rakefile +++ b/railties/lib/rails/generators/rails/plugin/templates/Rakefile @@ -19,6 +19,10 @@ APP_RAKEFILE = File.expand_path("../<%= dummy_path -%>/Rakefile", __FILE__) load 'rails/tasks/engine.rake' <% end %> +<% if engine? -%> +load 'rails/tasks/statistics.rake' +<% end %> + <% unless options[:skip_gemspec] -%> Bundler::GemHelper.install_tasks diff --git a/railties/lib/rails/tasks/statistics.rake b/railties/lib/rails/tasks/statistics.rake index c1674c72ad..019aaf9add 100644 --- a/railties/lib/rails/tasks/statistics.rake +++ b/railties/lib/rails/tasks/statistics.rake @@ -1,22 +1,23 @@ -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, "#{Rails.root}/#{dir}" ] }.select { |name, dir| File.directory?(dir) } - -desc "Report code statistics (KLOCs, etc) from the application" +desc "Report code statistics (KLOCs, etc) from the application or engine" task :stats do 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 -end +end
\ No newline at end of file |