Skip to content

Commit

Permalink
Merge pull request #15299 from andriytyurnikov/engine_friendly_rake_s…
Browse files Browse the repository at this point in the history
…tats

rake stats for engines
  • Loading branch information
rafaelfranca committed May 24, 2014
2 parents 528e590 + b71f5f4 commit a9ced73
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 19 deletions.
4 changes: 4 additions & 0 deletions railties/lib/rails/generators/rails/plugin/templates/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
39 changes: 20 additions & 19 deletions railties/lib/rails/tasks/statistics.rake
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit a9ced73

Please sign in to comment.