diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2005-09-27 22:09:21 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2005-09-27 22:09:21 +0000 |
commit | ec019d7bc17e7bcf99545fa7698b3bcb419d2632 (patch) | |
tree | 45d7b649f71ce9c848de98b1f10254c2359a8382 /railties | |
parent | fcd0133f691b8228b8b08bd3c52c3acc1b3692e3 (diff) | |
download | rails-ec019d7bc17e7bcf99545fa7698b3bcb419d2632.tar.gz rails-ec019d7bc17e7bcf99545fa7698b3bcb419d2632.tar.bz2 rails-ec019d7bc17e7bcf99545fa7698b3bcb419d2632.zip |
Ticket 2297 - rake stats clearly labels functional and unit tests
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2373 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'railties')
-rw-r--r-- | railties/lib/code_statistics.rb | 9 | ||||
-rw-r--r-- | railties/lib/tasks/statistics.rake | 16 |
2 files changed, 14 insertions, 11 deletions
diff --git a/railties/lib/code_statistics.rb b/railties/lib/code_statistics.rb index ea3c1ad66d..75334c4610 100644 --- a/railties/lib/code_statistics.rb +++ b/railties/lib/code_statistics.rb @@ -1,4 +1,7 @@ class CodeStatistics + + TEST_TYPES = ['Unit tests', 'Functional tests'] + def initialize(*pairs) @pairs = pairs @statistics = calculate_statistics @@ -55,13 +58,13 @@ class CodeStatistics def calculate_code code_loc = 0 - @statistics.each { |k, v| code_loc += v['codelines'] unless ['Units', 'Functionals'].include? k } + @statistics.each { |k, v| code_loc += v['codelines'] unless TEST_TYPES.include? k } code_loc end def calculate_tests test_loc = 0 - @statistics.each { |k, v| test_loc += v['codelines'] if ['Units', 'Functionals'].include? k } + @statistics.each { |k, v| test_loc += v['codelines'] if TEST_TYPES.include? k } test_loc end @@ -79,7 +82,7 @@ class CodeStatistics m_over_c = (statistics["methods"] / statistics["classes"]) rescue m_over_c = 0 loc_over_m = (statistics["codelines"] / statistics["methods"]) - 2 rescue loc_over_m = 0 - start = if ['Units', 'Functionals'].include? name + start = if TEST_TYPES.include? name "| #{name.ljust(18)} " else "| #{name.ljust(20)} " diff --git a/railties/lib/tasks/statistics.rake b/railties/lib/tasks/statistics.rake index b89f1bf649..01c944d558 100644 --- a/railties/lib/tasks/statistics.rake +++ b/railties/lib/tasks/statistics.rake @@ -1,12 +1,12 @@ STATS_DIRECTORIES = [ - %w(Helpers app/helpers), - %w(Controllers app/controllers), - %w(APIs app/apis), - %w(Components components), - %w(Functionals test/functional), - %w(Models app/models), - %w(Units test/unit), - %w(Libraries lib/) + %w(Helpers app/helpers), + %w(Controllers app/controllers), + %w(APIs app/apis), + %w(Components components), + %w(Functional\ tests test/functional), + %w(Models app/models), + %w(Unit\ tests test/unit), + %w(Libraries lib/) ].collect { |name, dir| [ name, "#{RAILS_ROOT}/#{dir}" ] }.select { |name, dir| File.directory?(dir) } desc "Report code statistics (KLOCs, etc) from the application" |