code_statistics 0.1.3 → 0.1.4
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/VERSION +1 -1
- data/code_statistics.gemspec +1 -1
- data/lib/code_statistics/code_statistics.rb +18 -13
- data/lib/tasks/code_stats.rb +8 -1
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.4
|
data/code_statistics.gemspec
CHANGED
@@ -5,10 +5,23 @@ module CodeStatistics
|
|
5
5
|
|
6
6
|
|
7
7
|
def initialize(*pairs)
|
8
|
-
@pairs
|
9
|
-
@
|
10
|
-
|
11
|
-
@
|
8
|
+
@pairs = pairs
|
9
|
+
@test_types = []
|
10
|
+
directory = Dir.pwd
|
11
|
+
@specs_found = false
|
12
|
+
add_test_type("Model specs") if local_file_exists?(directory, 'spec/models')
|
13
|
+
add_test_type("View specs") if local_file_exists?(directory, 'spec/views')
|
14
|
+
add_test_type("Controller specs") if local_file_exists?(directory, 'spec/controllers')
|
15
|
+
add_test_type("Helper specs") if local_file_exists?(directory, 'spec/helpers')
|
16
|
+
add_test_type("Library specs") if local_file_exists?(directory, 'spec/lib')
|
17
|
+
add_test_type("Routing specs") if local_file_exists?(directory, 'spec/routing')
|
18
|
+
add_test_type("Integration specs") if local_file_exists?(directory, 'spec/integration')
|
19
|
+
if @specs_found==false && local_file_exists?(directory, 'spec')
|
20
|
+
@pairs << %w(Specs spec)
|
21
|
+
add_test_type("Specs")
|
22
|
+
end
|
23
|
+
@statistics = calculate_statistics
|
24
|
+
@total = calculate_total if pairs.length > 1
|
12
25
|
end
|
13
26
|
|
14
27
|
def to_s
|
@@ -38,20 +51,12 @@ module CodeStatistics
|
|
38
51
|
end
|
39
52
|
|
40
53
|
def add_test_type(test_type)
|
54
|
+
@specs_found = true
|
41
55
|
@test_types << test_type
|
42
56
|
end
|
43
57
|
|
44
58
|
def calculate_directory_statistics(directory, pattern = /.*\.rb$/)
|
45
59
|
stats = { "lines" => 0, "codelines" => 0, "classes" => 0, "methods" => 0 }
|
46
|
-
|
47
|
-
add_test_type("Model specs") if local_file_exists?(directory, 'spec/models')
|
48
|
-
add_test_type("View specs") if local_file_exists?(directory, 'spec/views')
|
49
|
-
add_test_type("Controller specs") if local_file_exists?(directory, 'spec/controllers')
|
50
|
-
add_test_type("Helper specs") if local_file_exists?(directory, 'spec/helpers')
|
51
|
-
add_test_type("Library specs") if local_file_exists?(directory, 'spec/lib')
|
52
|
-
add_test_type("Routing specs") if local_file_exists?(directory, 'spec/routing')
|
53
|
-
add_test_type("Integration specs") if local_file_exists?(directory, 'spec/integration')
|
54
|
-
add_test_type("Specs") if if local_file_exists?(directory, 'spec')
|
55
60
|
|
56
61
|
Dir.foreach(directory) do |file_name|
|
57
62
|
if File.stat(directory + "/" + file_name).directory? and (/^\./ !~ file_name)
|
data/lib/tasks/code_stats.rb
CHANGED
@@ -6,7 +6,14 @@ STATS_DIRECTORIES = [
|
|
6
6
|
%w(APIs app/apis),
|
7
7
|
%w(Integration\ tests test/integration),
|
8
8
|
%w(Functional\ tests test/functional),
|
9
|
-
%w(Unit\ tests test/unit)
|
9
|
+
%w(Unit\ tests test/unit),
|
10
|
+
%w(Model\ specs spec/models),
|
11
|
+
%w(View\ specs spec/views),
|
12
|
+
%w(Controller\ specs spec/controllers),
|
13
|
+
%w(Helper\ specs spec/helpers),
|
14
|
+
%w(Library\ specs spec/lib),
|
15
|
+
%w(Routing\ specs spec/routing),
|
16
|
+
%w(Integration\ specs spec/integration)
|
10
17
|
].collect { |name, dir| [ name, "#{Dir.pwd}/#{dir}" ] }.select { |name, dir| File.directory?(dir) }
|
11
18
|
|
12
19
|
desc "Report code statistics (KLOCs, etc) from the application"
|