code_statistics 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/code_statistics.gemspec +2 -2
- data/lib/code_statistics/code_statistics.rb +8 -4
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.6
|
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.6"
|
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-22}
|
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}
|
@@ -1,6 +1,8 @@
|
|
1
1
|
module CodeStatistics
|
2
2
|
class CodeStatistics #:nodoc:
|
3
3
|
|
4
|
+
FILTER = /.*\.rb$/
|
5
|
+
|
4
6
|
attr_reader :print_buffer
|
5
7
|
|
6
8
|
def initialize(pairs, ignore_file_globs = [])
|
@@ -30,8 +32,10 @@ module CodeStatistics
|
|
30
32
|
entries.each do |entry|
|
31
33
|
entry_path = File.join(dir,entry)
|
32
34
|
if File.directory?(entry_path)
|
33
|
-
|
34
|
-
|
35
|
+
if Dir.entries(entry_path).select{|path| path.match(FILTER)}.length > 0
|
36
|
+
@pairs << [entry_path, entry_path]
|
37
|
+
has_directories = true
|
38
|
+
end
|
35
39
|
end
|
36
40
|
end
|
37
41
|
@pairs << [dir, dir] unless has_directories
|
@@ -83,7 +87,7 @@ module CodeStatistics
|
|
83
87
|
@ignore_files.include?(File.expand_path(file_path))
|
84
88
|
end
|
85
89
|
|
86
|
-
def calculate_directory_statistics(directory, pattern =
|
90
|
+
def calculate_directory_statistics(directory, pattern = FILTER)
|
87
91
|
stats = { "lines" => 0, "codelines" => 0, "classes" => 0, "methods" => 0 }
|
88
92
|
|
89
93
|
Dir.foreach(directory) do |file_name|
|
@@ -147,7 +151,7 @@ module CodeStatistics
|
|
147
151
|
def print_line(name, statistics)
|
148
152
|
m_over_c = (statistics["methods"] / statistics["classes"]) rescue m_over_c = 0
|
149
153
|
loc_over_m = (statistics["codelines"] / statistics["methods"]) rescue loc_over_m = 0
|
150
|
-
loc_over_m =
|
154
|
+
loc_over_m = loc_over_m - 2 if loc_over_m >= 2
|
151
155
|
|
152
156
|
start = if test_types.include? name
|
153
157
|
"| #{name.ljust(20)} "
|
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.6
|
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-22 00:00:00 -05:00
|
13
13
|
default_executable: code_statistics
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|