relevance-rcov 0.8.2.1 → 0.8.3.0
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 +5 -13
- data/bin/rcov +3 -5
- data/ext/rcovrt/extconf.rb +19 -21
- data/lib/rcov/formatters/base_formatter.rb +292 -0
- data/lib/rcov/formatters/full_text_report.rb +55 -0
- data/lib/rcov/formatters/html_coverage.rb +258 -0
- data/lib/rcov/formatters/text_coverage_diff.rb +199 -0
- data/lib/rcov/formatters/text_report.rb +36 -0
- data/lib/rcov/formatters/text_summary.rb +15 -0
- data/lib/rcov/formatters.rb +14 -0
- data/lib/rcov/report.rb +0 -63
- data/lib/rcov/templates/detail.html.erb +102 -0
- data/lib/rcov/templates/index.html.erb +100 -0
- data/lib/rcov/templates/screen.css +144 -0
- data/lib/rcov/version.rb +4 -3
- data/lib/rcov.rb +21 -1
- data/test/assets/sample_05.rb +0 -4
- data/test/code_coverage_analyzer_test.rb +1 -5
- data/test/file_statistics_test.rb +3 -3
- metadata +15 -7
- data/lib/rcov/rexml_extensions.rb +0 -44
- data/lib/rcov/xx.rb +0 -754
data/lib/rcov.rb
CHANGED
@@ -15,7 +15,19 @@ require 'rcov/formatters'
|
|
15
15
|
SCRIPT_LINES__ = {} unless defined? SCRIPT_LINES__
|
16
16
|
|
17
17
|
module Rcov
|
18
|
+
|
19
|
+
# TODO: Move to Ruby 1.8.6 Backport module
|
20
|
+
unless RUBY_VERSION =~ /1.9/
|
21
|
+
|
22
|
+
class ::String
|
18
23
|
|
24
|
+
def lines
|
25
|
+
map
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
19
31
|
# Rcov::CoverageInfo is but a wrapper for an array, with some additional
|
20
32
|
# checks. It is returned by FileStatistics#coverage.
|
21
33
|
class CoverageInfo
|
@@ -137,7 +149,15 @@ class FileStatistics
|
|
137
149
|
indices.each {|i| count += 1 if @coverage[i] }
|
138
150
|
1.0 * count / indices.size
|
139
151
|
end
|
140
|
-
|
152
|
+
|
153
|
+
def code_coverage_for_report
|
154
|
+
code_coverage * 100
|
155
|
+
end
|
156
|
+
|
157
|
+
def total_coverage_for_report
|
158
|
+
total_coverage * 100
|
159
|
+
end
|
160
|
+
|
141
161
|
# Number of lines of code (loc).
|
142
162
|
def num_code_lines
|
143
163
|
(0...@lines.size).select{|i| is_code? i}.size
|
data/test/assets/sample_05.rb
CHANGED
@@ -47,9 +47,7 @@ EOF
|
|
47
47
|
line_info, cov_info, count_info = analyzer.data(sample_file)
|
48
48
|
assert_equal(lines, line_info)
|
49
49
|
assert_equal([true, true, false, false, true, false, true], cov_info)
|
50
|
-
assert_equal([1, 2, 0, 0, 1, 0, 11], count_info)
|
51
|
-
# JRUBY reports an if x==blah as hitting this type of line once, JRUBY also optimizes this stuff so you'd have to run with --debug to get "extra" information. MRI hits it twice.
|
52
|
-
assert_equal([1, 1, 0, 0, 1, 0, 11], count_info) if PLATFORM =~ /java/
|
50
|
+
assert_equal([1, 2, 0, 0, 1, 0, 11], count_info)
|
53
51
|
analyzer.reset
|
54
52
|
assert_equal(nil, analyzer.data(sample_file))
|
55
53
|
assert_equal([], analyzer.analyzed_files)
|
@@ -88,8 +86,6 @@ EOF
|
|
88
86
|
analyzer = Rcov::CodeCoverageAnalyzer.new
|
89
87
|
analyzer.run_hooked{ load sample_file }
|
90
88
|
line_info, cov_info, count_info = analyzer.data(sample_file)
|
91
|
-
assert_equal([1, 2, 0, 0, 1, 0, 11], count_info) unless (defined? PLATFORM && PLATFORM =~ /java/) || RUBY_VERSION =~ /1.9/
|
92
|
-
# JRUBY reports an if x==blah as hitting this type of line once, JRUBY also optimizes this stuff so you'd have to run with --debug to get "extra" information. MRI hits it twice.
|
93
89
|
assert_equal([1, 2, 0, 0, 1, 0, 11], count_info) if RUBY_VERSION =~ /1.9/
|
94
90
|
|
95
91
|
analyzer.reset
|
@@ -464,8 +464,8 @@ class TestFileStatistics < Test::Unit::TestCase
|
|
464
464
|
|
465
465
|
def code_info_from_string(str)
|
466
466
|
str = str.gsub(/^\s*/,"")
|
467
|
-
[ str.map{|line| line.sub(/^\d+ /, "") },
|
468
|
-
str.map{|line| line[/^\d+/].to_i > 0},
|
469
|
-
str.map{|line| line[/^\d+/].to_i } ]
|
467
|
+
[ str.lines.map{|line| line.sub(/^\d+ /, "") },
|
468
|
+
str.lines.map{|line| line[/^\d+/].to_i > 0},
|
469
|
+
str.lines.map{|line| line[/^\d+/].to_i } ]
|
470
470
|
end
|
471
471
|
end
|
metadata
CHANGED
@@ -1,21 +1,21 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: relevance-rcov
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
+
- Relevance
|
8
|
+
- Chad Humphries (spicycode)
|
7
9
|
- Mauricio Fernandez
|
8
|
-
- Chad Humphries
|
9
|
-
- Aaron Bedra
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain:
|
13
|
-
date: 2009-
|
13
|
+
date: 2009-05-08 00:00:00 -07:00
|
14
14
|
default_executable: rcov
|
15
15
|
dependencies: []
|
16
16
|
|
17
17
|
description: rcov is a code coverage tool for Ruby. It is commonly used for viewing overall test unit coverage of target code. It features fast execution (20-300 times faster than previous tools), multiple analysis modes, XHTML and several kinds of text reports, easy automation with Rake via a RcovTask, fairly accurate coverage information through code linkage inference using simple heuristics, colorblind-friendliness...
|
18
|
-
email:
|
18
|
+
email: opensource@thinkrelevance.com
|
19
19
|
executables:
|
20
20
|
- rcov
|
21
21
|
extensions:
|
@@ -28,11 +28,19 @@ files:
|
|
28
28
|
- bin/rcov
|
29
29
|
- lib/rcov.rb
|
30
30
|
- lib/rcov/lowlevel.rb
|
31
|
-
- lib/rcov/xx.rb
|
32
31
|
- lib/rcov/version.rb
|
33
32
|
- lib/rcov/report.rb
|
34
33
|
- lib/rcov/rcovtask.rb
|
35
|
-
- lib/rcov/
|
34
|
+
- lib/rcov/formatters.rb
|
35
|
+
- lib/rcov/formatters/base_formatter.rb
|
36
|
+
- lib/rcov/formatters/full_text_report.rb
|
37
|
+
- lib/rcov/formatters/html_coverage.rb
|
38
|
+
- lib/rcov/formatters/text_coverage_diff.rb
|
39
|
+
- lib/rcov/formatters/text_report.rb
|
40
|
+
- lib/rcov/formatters/text_summary.rb
|
41
|
+
- lib/rcov/templates/index.html.erb
|
42
|
+
- lib/rcov/templates/detail.html.erb
|
43
|
+
- lib/rcov/templates/screen.css
|
36
44
|
- ext/rcovrt/extconf.rb
|
37
45
|
- ext/rcovrt/1.8/rcovrt.c
|
38
46
|
- ext/rcovrt/1.9/rcovrt.c
|
@@ -1,44 +0,0 @@
|
|
1
|
-
require 'rexml/document'
|
2
|
-
require 'rexml/formatters/pretty'
|
3
|
-
|
4
|
-
module Rcov
|
5
|
-
module REXMLExtensions
|
6
|
-
|
7
|
-
def self.fix_pretty_formatter_wrap
|
8
|
-
REXML::Formatters::Pretty.class_eval do
|
9
|
-
include PrettyFormatterWrapFix
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
# Fix for this bug: http://clint-hill.com/2008/10/02/a-bug-in-ruby-did-i-just-find-that/
|
14
|
-
# Also known from this fun exception:
|
15
|
-
#
|
16
|
-
# /usr/local/ruby/lib/ruby/1.8/rexml/formatters/pretty.rb:131:in
|
17
|
-
# `[]': no implicit conversion from nil to integer (TypeError)
|
18
|
-
#
|
19
|
-
# This bug was fixed in Ruby with this changeset http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=19487
|
20
|
-
# ...which should mean that this bug only affects Ruby 1.8.6. The latest stable version of 1.8.7 (and up) should be fine.
|
21
|
-
module PrettyFormatterWrapFix
|
22
|
-
|
23
|
-
def self.included(base)
|
24
|
-
base.class_eval do
|
25
|
-
def wrap(string, width)
|
26
|
-
# Recursively wrap string at width.
|
27
|
-
return string if string.length <= width
|
28
|
-
place = string.rindex(' ', width) # Position in string with last ' ' before cutoff
|
29
|
-
return string if place.nil?
|
30
|
-
return string[0,place] + "\n" + wrap(string[place+1..-1], width)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
end
|
36
|
-
|
37
|
-
def self.init!
|
38
|
-
if RUBY_VERSION == "1.8.6"
|
39
|
-
fix_pretty_formatter_wrap
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
end
|