spicycode-rcov 0.8.1.5.5 → 0.8.1.5.6

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.
@@ -0,0 +1,44 @@
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
data/lib/rcov/version.rb CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  module Rcov
6
6
 
7
- VERSION = "0.8.1.5.5"
7
+ VERSION = "0.8.1.5.6"
8
8
  RELEASE_DATE = "2008-10-29"
9
9
  RCOVRT_ABI = [2,0,0]
10
10
  UPSTREAM_URL = "http://github.com/spicycode/rcov"
@@ -0,0 +1,23 @@
1
+ require File.dirname(__FILE__) + '/test_helper'
2
+ require 'rcov/rexml_extensions'
3
+
4
+ class TestRexml < Test::Unit::TestCase
5
+
6
+ def test_wrap_with_long_lines_without_spaces_should_not_break_wrap
7
+ Rcov::REXMLExtensions.fix_pretty_formatter_wrap
8
+ pretty_formatter = ::REXML::Formatters::Pretty.new
9
+ long_string = "this-is-a-long-string-without-any-spaces-to-try-to-break-rexml-formatter-and-it-is-over-100-characters-long"
10
+ pretty_formatter.instance_eval { wrap(long_string, 100) } # avoid send, it can't bypass private methods in ruby19
11
+ end
12
+
13
+ def test_wrap_original_behavior_should_be_preserved
14
+ pretty_formatter = REXML::Formatters::Pretty.new
15
+ str = "This string should be wrapped at 40 characters"
16
+ pretty_formatter.instance_eval do
17
+ str = wrap(str, 40)
18
+ end # avoid send, it can't bypass private methods in ruby19
19
+ assert_equal("This string should be wrapped at 40\ncharacters", str)
20
+
21
+ end
22
+
23
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spicycode-rcov
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1.5.5
4
+ version: 0.8.1.5.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mauricio Fernandez
@@ -31,6 +31,7 @@ files:
31
31
  - lib/rcov/version.rb
32
32
  - lib/rcov/rant.rb
33
33
  - lib/rcov/report.rb
34
+ - lib/rcov/rexml_extensions.rb
34
35
  - lib/rcov/rcovtask.rb
35
36
  - ext/rcovrt/extconf.rb
36
37
  - ext/rcovrt/rcovrt.c
@@ -56,6 +57,7 @@ files:
56
57
  - test/turn_off_rcovrt.rb
57
58
  - test/call_site_analyzer_test.rb
58
59
  - test/assets/sample_05.rb
60
+ - test/rexml_test.rb
59
61
  - rcov.vim
60
62
  - rcov.el
61
63
  - setup.rb