code_statistics 0.2.10 → 0.2.11
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/bin/code_statistics +1 -0
- data/code_statistics.gemspec +3 -3
- data/lib/code_statistics/code_statistics.rb +14 -11
- metadata +24 -13
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.11
|
data/bin/code_statistics
CHANGED
data/code_statistics.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{code_statistics}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.11"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Dan Mayer"]
|
12
|
-
s.date = %q{2010-02-
|
12
|
+
s.date = %q{2010-02-25}
|
13
13
|
s.default_executable = %q{code_statistics}
|
14
14
|
s.description = %q{"This is a port of the rails 'rake stats' method so it can be made more robust and work for non rails projects. New features may eventually be added as well."}
|
15
15
|
s.email = %q{dan@devver.net}
|
@@ -36,7 +36,7 @@ Gem::Specification.new do |s|
|
|
36
36
|
s.homepage = %q{http://github.com/danmayer/code_statistics}
|
37
37
|
s.rdoc_options = ["--charset=UTF-8"]
|
38
38
|
s.require_paths = ["lib"]
|
39
|
-
s.rubygems_version = %q{1.3.
|
39
|
+
s.rubygems_version = %q{1.3.6}
|
40
40
|
s.summary = %q{Making a gem of the normal rails rake stats method, to make it more robust and work on non rails projects}
|
41
41
|
s.test_files = [
|
42
42
|
"test/code_statistics_test.rb",
|
@@ -3,7 +3,7 @@ require 'pathname'
|
|
3
3
|
module CodeStatistics
|
4
4
|
class CodeStatistics #:nodoc:
|
5
5
|
|
6
|
-
FILTER = /.*\.rb$/
|
6
|
+
FILTER = /.*\.(rb|feature)$/
|
7
7
|
|
8
8
|
attr_reader :print_buffer
|
9
9
|
|
@@ -16,14 +16,10 @@ module CodeStatistics
|
|
16
16
|
|
17
17
|
@pairs = remove_duplicate_pairs(@pairs)
|
18
18
|
|
19
|
-
directories_to_search = ['app','test','spec','merb',
|
19
|
+
directories_to_search = ['app','test','spec','merb', 'bin']
|
20
20
|
directories_to_search = remove_included_pairs(directories_to_search, @pairs)
|
21
21
|
recursively_add_directories(directories_to_search)
|
22
|
-
|
23
|
-
@pairs.each do |key, dir_path|
|
24
|
-
add_test_type(key) if dir_path.match(/^test/) || dir_path.match(/^spec/) || dir_path.match(/^features/) ||
|
25
|
-
dir_path.match(/test$/) || dir_path.match(/spec$/) || dir_path.match(/features$/)
|
26
|
-
end
|
22
|
+
add_test_types(@pairs)
|
27
23
|
|
28
24
|
@statistics = calculate_statistics
|
29
25
|
@total = calculate_total if pairs.length > 1
|
@@ -87,7 +83,7 @@ module CodeStatistics
|
|
87
83
|
|
88
84
|
private
|
89
85
|
|
90
|
-
#user
|
86
|
+
#user supplied paths and set paths might slight differ like path/name and path/name/ this filters those out
|
91
87
|
def remove_duplicate_pairs(pairs)
|
92
88
|
unique_pairs = []
|
93
89
|
paths = pairs.map{|pair| [pair.first, Pathname.new(pair.last).realpath.to_s] }
|
@@ -95,8 +91,11 @@ module CodeStatistics
|
|
95
91
|
unique_pairs
|
96
92
|
end
|
97
93
|
|
98
|
-
def
|
99
|
-
|
94
|
+
def add_test_types(pairs)
|
95
|
+
pairs.each do |key, dir_path|
|
96
|
+
add_test_type(key) if dir_path.match(/^test/) || dir_path.match(/^spec/) || dir_path.match(/^features/) ||
|
97
|
+
dir_path.match(/test$/) || dir_path.match(/spec$/) || dir_path.match(/features$/)
|
98
|
+
end
|
100
99
|
end
|
101
100
|
|
102
101
|
def remove_included_pairs(directories_to_search, pairs)
|
@@ -108,6 +107,10 @@ module CodeStatistics
|
|
108
107
|
File.exist?(File.join(dir,filename))
|
109
108
|
end
|
110
109
|
|
110
|
+
def calculate_statistics
|
111
|
+
@pairs.inject({}) { |stats, pair| stats[pair.first] = calculate_directory_statistics(pair.last); stats }
|
112
|
+
end
|
113
|
+
|
111
114
|
def test_types
|
112
115
|
@test_types.uniq
|
113
116
|
end
|
@@ -138,7 +141,7 @@ module CodeStatistics
|
|
138
141
|
while line = f.gets
|
139
142
|
stats["lines"] += 1
|
140
143
|
stats["classes"] += 1 if line =~ /class [A-Z]/
|
141
|
-
stats["methods"] += 1 if line =~ /def [a-z]/
|
144
|
+
stats["methods"] += 1 if line =~ /(def [a-z]|should .* do|test .* do|it .* do)/
|
142
145
|
stats["codelines"] += 1 unless line =~ /^\s*$/ || line =~ /^\s*#/
|
143
146
|
end
|
144
147
|
end
|
metadata
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: code_statistics
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 2
|
8
|
+
- 11
|
9
|
+
version: 0.2.11
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- Dan Mayer
|
@@ -9,29 +14,33 @@ autorequire:
|
|
9
14
|
bindir: bin
|
10
15
|
cert_chain: []
|
11
16
|
|
12
|
-
date: 2010-02-
|
17
|
+
date: 2010-02-25 00:00:00 -05:00
|
13
18
|
default_executable: code_statistics
|
14
19
|
dependencies:
|
15
20
|
- !ruby/object:Gem::Dependency
|
16
21
|
name: thoughtbot-shoulda
|
17
|
-
|
18
|
-
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
24
|
requirements:
|
21
25
|
- - ">="
|
22
26
|
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
23
29
|
version: "0"
|
24
|
-
|
30
|
+
type: :development
|
31
|
+
version_requirements: *id001
|
25
32
|
- !ruby/object:Gem::Dependency
|
26
33
|
name: test-construct
|
27
|
-
|
28
|
-
|
29
|
-
version_requirements: !ruby/object:Gem::Requirement
|
34
|
+
prerelease: false
|
35
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
30
36
|
requirements:
|
31
37
|
- - ">="
|
32
38
|
- !ruby/object:Gem::Version
|
39
|
+
segments:
|
40
|
+
- 0
|
33
41
|
version: "0"
|
34
|
-
|
42
|
+
type: :development
|
43
|
+
version_requirements: *id002
|
35
44
|
description: "\"This is a port of the rails 'rake stats' method so it can be made more robust and work for non rails projects. New features may eventually be added as well.\""
|
36
45
|
email: dan@devver.net
|
37
46
|
executables:
|
@@ -68,18 +77,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
68
77
|
requirements:
|
69
78
|
- - ">="
|
70
79
|
- !ruby/object:Gem::Version
|
80
|
+
segments:
|
81
|
+
- 0
|
71
82
|
version: "0"
|
72
|
-
version:
|
73
83
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
84
|
requirements:
|
75
85
|
- - ">="
|
76
86
|
- !ruby/object:Gem::Version
|
87
|
+
segments:
|
88
|
+
- 0
|
77
89
|
version: "0"
|
78
|
-
version:
|
79
90
|
requirements: []
|
80
91
|
|
81
92
|
rubyforge_project:
|
82
|
-
rubygems_version: 1.3.
|
93
|
+
rubygems_version: 1.3.6
|
83
94
|
signing_key:
|
84
95
|
specification_version: 3
|
85
96
|
summary: Making a gem of the normal rails rake stats method, to make it more robust and work on non rails projects
|