aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
authorAndriy Tyurnikov <Andriy.Tyurnikov@gmail.com>2014-05-26 02:19:53 +0300
committerAndriy Tyurnikov <Andriy.Tyurnikov@gmail.com>2014-05-26 02:19:53 +0300
commit272f80dc16505fd52b7abfabdbba14192b608ba7 (patch)
treed86020b55233ce8777f2679f6243bc31713a282e /railties
parent6c30717f8c182dc05f63779b3a9a532fb9076b05 (diff)
downloadrails-272f80dc16505fd52b7abfabdbba14192b608ba7.tar.gz
rails-272f80dc16505fd52b7abfabdbba14192b608ba7.tar.bz2
rails-272f80dc16505fd52b7abfabdbba14192b608ba7.zip
simple solution that brings rake stats task to every kind of rails project
Diffstat (limited to 'railties')
-rw-r--r--railties/lib/rails/tasks/statistics.rake40
1 files changed, 22 insertions, 18 deletions
diff --git a/railties/lib/rails/tasks/statistics.rake b/railties/lib/rails/tasks/statistics.rake
index 019aaf9add..ae5a7d2759 100644
--- a/railties/lib/rails/tasks/statistics.rake
+++ b/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 \ No newline at end of file