code_statistics 0.2.6 → 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/code_statistics.gemspec +5 -5
- data/lib/code_statistics/code_statistics.rb +21 -9
- data/test/code_statistics_test.rb +25 -1
- metadata +3 -3
data/Rakefile
CHANGED
@@ -12,7 +12,7 @@ begin
|
|
12
12
|
gem.homepage = "http://github.com/danmayer/code_statistics"
|
13
13
|
gem.authors = ["Dan Mayer"]
|
14
14
|
gem.add_development_dependency "thoughtbot-shoulda"
|
15
|
-
gem.add_development_dependency "
|
15
|
+
gem.add_development_dependency "test-construct"
|
16
16
|
gem.executables = ['code_statistics']
|
17
17
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
18
18
|
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.7
|
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.7"
|
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-01-
|
12
|
+
s.date = %q{2010-01-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}
|
@@ -49,13 +49,13 @@ Gem::Specification.new do |s|
|
|
49
49
|
|
50
50
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
51
51
|
s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
52
|
-
s.add_development_dependency(%q<
|
52
|
+
s.add_development_dependency(%q<test-construct>, [">= 0"])
|
53
53
|
else
|
54
54
|
s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
55
|
-
s.add_dependency(%q<
|
55
|
+
s.add_dependency(%q<test-construct>, [">= 0"])
|
56
56
|
end
|
57
57
|
else
|
58
58
|
s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
59
|
-
s.add_dependency(%q<
|
59
|
+
s.add_dependency(%q<test-construct>, [">= 0"])
|
60
60
|
end
|
61
61
|
end
|
@@ -28,19 +28,31 @@ module CodeStatistics
|
|
28
28
|
if File.directory?(dir)
|
29
29
|
entries = Dir.entries(dir)
|
30
30
|
entries = entries.reject{ |entry| entry=='.' || entry=='..' }
|
31
|
-
has_directories =
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
31
|
+
has_directories = add_sub_directory(entries, dir)
|
32
|
+
@pairs << [dir, dir] unless has_directories
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def add_sub_directory(entries, dir)
|
38
|
+
has_directories = false
|
39
|
+
entries = entries.reject{ |entry| entry=='.' || entry=='..' }
|
40
|
+
entries.each do |entry|
|
41
|
+
entry_path = File.join(dir,entry)
|
42
|
+
if File.directory?(entry_path)
|
43
|
+
if Dir.entries(entry_path).select{|path| path.match(FILTER)}.length > 0
|
44
|
+
@pairs << [entry_path, entry_path]
|
45
|
+
has_directories = true
|
46
|
+
else
|
47
|
+
has_directories = add_sub_directory(Dir.entries(entry_path), entry_path)
|
48
|
+
if has_directories == false && Dir.entries(entry_path).select{|path| path.match(FILTER)}.length > 0
|
49
|
+
@pairs << [entry_path, entry_path]
|
50
|
+
has_directories = true
|
39
51
|
end
|
40
52
|
end
|
41
|
-
@pairs << [dir, dir] unless has_directories
|
42
53
|
end
|
43
54
|
end
|
55
|
+
has_directories
|
44
56
|
end
|
45
57
|
|
46
58
|
def collect_files_to_ignore(ignore_file_globs)
|
@@ -52,6 +52,31 @@ class CodeStatisticsTest < Test::Unit::TestCase
|
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
|
+
should "add spec sub sub directories and count as test code" do
|
56
|
+
within_construct do |construct|
|
57
|
+
dir = construct.directory("spec")
|
58
|
+
sub_dir = dir.directory("models")
|
59
|
+
sub_dir2 = sub_dir.directory("controllers")
|
60
|
+
file = sub_dir2.file("fake.rb", "this\nis\n\lame\n")
|
61
|
+
code_stats = CodeStatistics::CodeStatistics.new([])
|
62
|
+
assert code_stats.to_s.match(/spec\/models\/controllers/)
|
63
|
+
assert code_stats.to_s.match(/Test LOC: 3/)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
should "add spec sub sub directories but add highest level directory with test files and count as test code" do
|
68
|
+
within_construct do |construct|
|
69
|
+
dir = construct.directory("spec")
|
70
|
+
sub_dir = dir.directory("models")
|
71
|
+
file = sub_dir.file("top_fake.rb", "this\nis\n\lame\n")
|
72
|
+
sub_dir2 = sub_dir.directory("controllers")
|
73
|
+
file = sub_dir2.file("fake.rb", "this\nis\n\lame\n")
|
74
|
+
code_stats = CodeStatistics::CodeStatistics.new([])
|
75
|
+
assert code_stats.to_s.match(/spec\/models/)
|
76
|
+
assert code_stats.to_s.match(/Test LOC: 6/)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
55
80
|
should "add spec root directory and count as test code" do
|
56
81
|
within_construct do |construct|
|
57
82
|
dir = construct.directory("spec")
|
@@ -126,5 +151,4 @@ class CodeStatisticsTest < Test::Unit::TestCase
|
|
126
151
|
end
|
127
152
|
end
|
128
153
|
|
129
|
-
|
130
154
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: code_statistics
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dan Mayer
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-01-
|
12
|
+
date: 2010-01-25 00:00:00 -05:00
|
13
13
|
default_executable: code_statistics
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -23,7 +23,7 @@ dependencies:
|
|
23
23
|
version: "0"
|
24
24
|
version:
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
|
-
name:
|
26
|
+
name: test-construct
|
27
27
|
type: :development
|
28
28
|
version_requirement:
|
29
29
|
version_requirements: !ruby/object:Gem::Requirement
|