Skip to content
Browse files

Merge pull request #15324 from andriytyurnikov/simple_rake_stats_for_…

…everything

simple solution that brings rake stats task to all rails project
  • Loading branch information...
2 parents 942194b + 272f80d commit 30d420097029328bf9e1c1d4b7a682892b0d4102 @senny senny committed May 26, 2014
Showing with 22 additions and 18 deletions.
  1. +22 −18 railties/lib/rails/tasks/statistics.rake
View
40 railties/lib/rails/tasks/statistics.rake
@@ -1,23 +1,27 @@
+# while having global constant is not good,
+# many 3rd party tools depend on it, like rspec-rails, cucumber-rails, etc
+# so if will be removed - deprecation warning is needed
+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 do |name, dir|
+ [ name, "#{File.dirname(Rake.application.rakefile_location)}/#{dir}" ]
+end.select { |name, dir| File.directory?(dir) }
+
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

0 comments on commit 30d4200

Please sign in to comment.
Something went wrong with that request. Please try again.