chrisjpowers-rdoc_metric 0.1.2 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/rdoc_metric +4 -2
- data/lib/rdoc_metric.rb +24 -3
- metadata +2 -3
data/bin/rdoc_metric
CHANGED
@@ -3,6 +3,8 @@
|
|
3
3
|
require 'rubygems'
|
4
4
|
require 'rdoc_metric'
|
5
5
|
|
6
|
-
|
6
|
+
paths = ARGV.empty? ?
|
7
|
+
[File.join('.', '**', '*.rb')] :
|
8
|
+
ARGV.map {|path| File.join(path, '**', '*.rb') }
|
7
9
|
|
8
|
-
puts RdocMetric.new(
|
10
|
+
puts RdocMetric.new(*paths).to_s
|
data/lib/rdoc_metric.rb
CHANGED
@@ -18,14 +18,17 @@ class RdocMetric
|
|
18
18
|
# Accepts a path that is sent to Dir.glob
|
19
19
|
#
|
20
20
|
# Ex: <tt>RdocMetric.new("/apps/my_app/**/*.rb")
|
21
|
-
def initialize(
|
22
|
-
files =
|
21
|
+
def initialize(*paths)
|
22
|
+
files = []
|
23
|
+
paths.each {|path| files.concat Dir.glob(path) }
|
23
24
|
@files = files.map {|f| RdocFile.new(f) }
|
24
25
|
end
|
25
26
|
|
26
27
|
# The overall percentage of coverage as an integer
|
27
28
|
def score
|
28
|
-
@files.inject(0) {|sum, file| sum += file.
|
29
|
+
documented = @files.inject(0) {|sum, file| sum += file.total_documented }
|
30
|
+
total = @files.inject(0) {|sum, file| sum += file.total_entities }
|
31
|
+
((documented.to_f / total) * 100).to_i
|
29
32
|
end
|
30
33
|
|
31
34
|
# Outputs the full listing of rdoc coverage for all parsed files.
|
@@ -47,6 +50,24 @@ class RdocMetric
|
|
47
50
|
parse_file!
|
48
51
|
end
|
49
52
|
|
53
|
+
# Count of total entities that could be documented.
|
54
|
+
def total_entities
|
55
|
+
@methods.length +
|
56
|
+
@classes.length +
|
57
|
+
@modules.length +
|
58
|
+
@attrs.length +
|
59
|
+
@constants.length
|
60
|
+
end
|
61
|
+
|
62
|
+
# Count of total documented entities
|
63
|
+
def total_documented
|
64
|
+
@methods.select {|b| b}.length +
|
65
|
+
@classes.select {|b| b}.length +
|
66
|
+
@modules.select {|b| b}.length +
|
67
|
+
@attrs.select {|b| b}.length +
|
68
|
+
@constants.select {|b| b}.length
|
69
|
+
end
|
70
|
+
|
50
71
|
# Percentage of rdoc coverage for this file as an Integer
|
51
72
|
def score
|
52
73
|
total = 0
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chrisjpowers-rdoc_metric
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Powers
|
@@ -28,7 +28,6 @@ files:
|
|
28
28
|
- lib/rdoc_metric.rb
|
29
29
|
has_rdoc: true
|
30
30
|
homepage: http://github.com/chrisjpowers/rdoc_metric
|
31
|
-
licenses:
|
32
31
|
post_install_message:
|
33
32
|
rdoc_options:
|
34
33
|
- --quiet
|
@@ -57,7 +56,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
57
56
|
requirements: []
|
58
57
|
|
59
58
|
rubyforge_project:
|
60
|
-
rubygems_version: 1.
|
59
|
+
rubygems_version: 1.2.0
|
61
60
|
signing_key:
|
62
61
|
specification_version: 3
|
63
62
|
summary: RdocMetric analyzes the Rdoc coverage of Ruby files.
|