diff options
author | Yehuda Katz <wycats@gmail.com> | 2011-11-23 11:11:40 -0800 |
---|---|---|
committer | Yehuda Katz <wycats@gmail.com> | 2011-11-23 11:11:40 -0800 |
commit | 8549f7a4f0c30c37050666f5661ea9e270a298fd (patch) | |
tree | 392afbec687f87073f7c01397a9e9258de4405f4 /railties/lib/rails/code_statistics.rb | |
parent | e9f63c55f8942139e17d83b9128e47968f0accc8 (diff) | |
parent | d78a7026fcd5eb0cd91e3da2a125ddfcf53e7a7a (diff) | |
download | rails-8549f7a4f0c30c37050666f5661ea9e270a298fd.tar.gz rails-8549f7a4f0c30c37050666f5661ea9e270a298fd.tar.bz2 rails-8549f7a4f0c30c37050666f5661ea9e270a298fd.zip |
Merge pull request #3731 from HeeL/master
code stats calculation
Diffstat (limited to 'railties/lib/rails/code_statistics.rb')
-rw-r--r-- | railties/lib/rails/code_statistics.rb | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/railties/lib/rails/code_statistics.rb b/railties/lib/rails/code_statistics.rb index e6822b75b7..435ea83ad8 100644 --- a/railties/lib/rails/code_statistics.rb +++ b/railties/lib/rails/code_statistics.rb @@ -38,11 +38,22 @@ class CodeStatistics #:nodoc: next unless file_name =~ pattern f = File.open(directory + "/" + file_name) - + comment_started = false while line = f.gets stats["lines"] += 1 - stats["classes"] += 1 if line =~ /class [A-Z]/ - stats["methods"] += 1 if line =~ /def [a-z]/ + if(comment_started) + if line =~ /^=end/ + comment_started = false + end + next + else + if line =~ /^=begin/ + comment_started = true + next + end + end + stats["classes"] += 1 if line =~ /^\s*class\s+[_A-Z]/ + stats["methods"] += 1 if line =~ /^\s*def\s+[_a-z]/ stats["codelines"] += 1 unless line =~ /^\s*$/ || line =~ /^\s*#/ end end |