code_statistics 0.2.9 → 0.2.10

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.9
1
+ 0.2.10
@@ -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.9"
8
+ s.version = "0.2.10"
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-05}
12
+ s.date = %q{2010-02-15}
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}
@@ -24,7 +24,7 @@ module CodeStatistics
24
24
  add_test_type(key) if dir_path.match(/^test/) || dir_path.match(/^spec/) || dir_path.match(/^features/) ||
25
25
  dir_path.match(/test$/) || dir_path.match(/spec$/) || dir_path.match(/features$/)
26
26
  end
27
-
27
+
28
28
  @statistics = calculate_statistics
29
29
  @total = calculate_total if pairs.length > 1
30
30
  end
@@ -50,8 +50,9 @@ module CodeStatistics
50
50
  @pairs << [entry_path, entry_path]
51
51
  has_directories = true
52
52
  else
53
- has_directories = add_sub_directory(Dir.entries(entry_path), entry_path)
54
- if has_directories == false && Dir.entries(entry_path).select{|path| path.match(FILTER)}.length > 0
53
+ sub_has_directories = add_sub_directory(Dir.entries(entry_path), entry_path)
54
+ has_directories = true if sub_has_directories
55
+ if sub_has_directories == false && Dir.entries(entry_path).select{|path| path.match(FILTER)}.length > 0
55
56
  @pairs << [entry_path, entry_path]
56
57
  has_directories = true
57
58
  end
@@ -15,6 +15,18 @@ class CodeStatisticsTest < Test::Unit::TestCase
15
15
  assert code_stats.to_s.match(/Code LOC: 6/)
16
16
  end
17
17
  end
18
+
19
+ should "not duplicate passed in directories with same paths with slashes" do
20
+ within_construct do |construct|
21
+ dir = construct.directory("lib")
22
+ file = dir.file("real.rb", "this\nis\n\lame\n")
23
+ controllers_dir = dir.directory("controllers")
24
+ file = controllers_dir.file("fake.rb", "this\nis\n\lame\n")
25
+ code_stats = CodeStatistics::CodeStatistics.new([["Libraries", 'lib'], ["libs", 'lib/']])
26
+ assert code_stats.to_s.match(/Libraries/)
27
+ assert code_stats.to_s.match(/Code LOC: 6/)
28
+ end
29
+ end
18
30
 
19
31
  should "find app controllers directory" do
20
32
  within_construct do |construct|
@@ -27,6 +39,18 @@ class CodeStatisticsTest < Test::Unit::TestCase
27
39
  end
28
40
  end
29
41
 
42
+ should "don't double count app directory when empty sub directories directory" do
43
+ within_construct do |construct|
44
+ dir = construct.directory("app")
45
+ controllers_dir = dir.directory("controllers")
46
+ file = controllers_dir.file("fake.rb", "this\nis\n\lame\n")
47
+ empty_sub_dir = dir.directory("zfolder")
48
+ code_stats = CodeStatistics::CodeStatistics.new([])
49
+ assert code_stats.to_s.match(/app\/controllers/)
50
+ assert code_stats.to_s.match(/Code LOC: 3/)
51
+ end
52
+ end
53
+
30
54
  should "find app non rails directory" do
31
55
  within_construct do |construct|
32
56
  dir = construct.directory("app")
@@ -111,6 +135,16 @@ class CodeStatisticsTest < Test::Unit::TestCase
111
135
  end
112
136
  end
113
137
 
138
+ should "count test directory even if passed in as full path" do
139
+ within_construct do |construct|
140
+ dir = construct.directory("test")
141
+ file = dir.file("fake.rb", "this\nis\n\lame\n")
142
+ code_stats = CodeStatistics::CodeStatistics.new([["test", dir.to_s]])
143
+ assert code_stats.to_s.match(/Test/)
144
+ assert code_stats.to_s.match(/Test LOC: 3/)
145
+ end
146
+ end
147
+
114
148
  should "calculate correct test to code ratio" do
115
149
  within_construct do |construct|
116
150
  dir = construct.directory("app")
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.9
4
+ version: 0.2.10
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-02-05 00:00:00 -05:00
12
+ date: 2010-02-15 00:00:00 -05:00
13
13
  default_executable: code_statistics
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency