simplecov 0.6.3 → 0.6.4

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -23,6 +23,7 @@ rdoc
23
23
  pkg
24
24
  tmp
25
25
  capybara*.html
26
+ .rvmrc
26
27
 
27
28
  ## PROJECT::SPECIFIC
28
29
 
data/CHANGELOG.md CHANGED
@@ -1,28 +1,39 @@
1
- v0.6.3 (2012-05-10)
2
- ===================
1
+ v0.6.4, 2012-05-10 ([changes](https://github.com/colszowka/simplecov/compare/v0.6.3...v0.6.4))
2
+ -------------------
3
3
 
4
- * Modified the API-changes for newer multi_json versions introduced with #122 and v0.6.2 so
4
+ * [BUGFIX] Encoding issues with ISO-8859-encoded source files fixed.
5
+ See https://github.com/colszowka/simplecov/pull/117. (thanks to @Deradon)
6
+ * [BUGFIX] Ensure ZeroDivisionErrors won't occur when calculating the coverage result, which previously
7
+ could happen in certain cases. See https://github.com/colszowka/simplecov/pull/128. (thanks to @japgolly)
8
+ * [REFACTORING] Changed a couple instance variable lookups so SimpleCov does not cause a lot of warnings when
9
+ running ruby at a higher warning level. See https://github.com/colszowka/simplecov/issues/106 and
10
+ https://github.com/colszowka/simplecov/pull/119. (thanks to @mvz and @gioele)
11
+
12
+
13
+ v0.6.3, 2012-05-10 ([changes](https://github.com/colszowka/simplecov/compare/v0.6.2...v0.6.3))
14
+ -------------------
15
+
16
+ * [BUGFIX] Modified the API-changes for newer multi_json versions introduced with #122 and v0.6.2 so
5
17
  they are backwards-compatible with older multi_json gems in order to avoid simplecov polluting
6
18
  the multi_json minimum version requirement for entire applications.
7
19
  See https://github.com/colszowka/simplecov/issues/132
8
20
  * Added appraisal gem to the test setup in order to run the test suite against both 1.0 and 1.3
9
21
  multi_json gems and ensure the above actually works :)
10
22
 
11
- v0.6.2 (2012-04-20)
12
- ===================
13
- **Note: Yanked 2012-05-10 because of backwards-incompatibilty of the updated multi_json api**
23
+ v0.6.2, 2012-04-20 ([changes](https://github.com/colszowka/simplecov/compare/v0.6.1...v0.6.2))
24
+ -------------------
14
25
 
15
- * Updated to latest version of MultiJSON and its new API (thanks to @sferik and @ronen).
26
+ * [Updated to latest version of MultiJSON and its new API (thanks to @sferik and @ronen).
16
27
  See https://github.com/colszowka/simplecov/pull/122
17
28
 
18
- v0.6.1 (2012-02-24)
19
- ===================
29
+ v0.6.1, 2012-02-24 ([changes](https://github.com/colszowka/simplecov/compare/v0.6.0...v0.6.1))
30
+ -------------------
20
31
 
21
32
  * [BUGFIX] Don't force-load Railtie on Rails < 3. Fixes regression introduced with
22
33
  #83. See https://github.com/colszowka/simplecov/issues/113
23
34
 
24
- v0.6.0 (2012-02-22)
25
- ===================
35
+ v0.6.0, 2012-02-22 ([changes](https://github.com/colszowka/simplecov/compare/v0.5.4...v0.6.0))
36
+ -------------------
26
37
 
27
38
  * [FEATURE] Auto-magic `rake simplecov` task for rails
28
39
  (see https://github.com/colszowka/simplecov/pull/83, thanks @sunaku)
@@ -37,8 +48,8 @@ v0.6.0 (2012-02-22)
37
48
  * Some refactorings and cleanups as usual. Please refer to the github compare view for a full
38
49
  list of changes: https://github.com/colszowka/simplecov/compare/v0.5.4...v0.6.0
39
50
 
40
- v0.5.4 (2011-10-12)
41
- ===================
51
+ v0.5.4, 2011-10-12 ([changes](https://github.com/colszowka/simplecov/compare/v0.5.3...v0.5.4))
52
+ -------------------
42
53
 
43
54
  * Do not give exit code 0 when there are exceptions prior to tests
44
55
  (see https://github.com/colszowka/simplecov/issues/41, thanks @nbogie)
@@ -50,8 +61,8 @@ v0.5.4 (2011-10-12)
50
61
  (see https://github.com/colszowka/simplecov/issues/86)
51
62
  * Readme formatted in Markdown :)
52
63
 
53
- v0.5.3 (2011-09-13)
54
- ===================
64
+ v0.5.3, 2011-09-13 ([changes](https://github.com/colszowka/simplecov/compare/v0.5.2...v0.5.3))
65
+ -------------------
55
66
 
56
67
  * Fix for encoding issues that came from the nocov processing mechanism
57
68
  (see https://github.com/colszowka/simplecov/issues/71)
@@ -65,14 +76,14 @@ v0.5.3 (2011-09-13)
65
76
  * Refactored nocov processing and made it configurable using SimpleCov.ncov_token (or it's
66
77
  alias SimpleCov.skip_token)
67
78
 
68
- v0.5.2 (2011-09-12)
69
- ===================
79
+ v0.5.2, 2011-09-12 ([changes](https://github.com/colszowka/simplecov/compare/v0.5.1...v0.5.2))
80
+ -------------------
70
81
 
71
82
  * Another fix for a bug in JSON processing introduced with MultiJSON in 0.5.1
72
83
  (see https://github.com/colszowka/simplecov/pull/75, thanks @sferik)
73
84
 
74
- v0.5.1 (2011-09-12)
75
- ===================
85
+ v0.5.1, 2011-09-12 ([changes](https://github.com/colszowka/simplecov/compare/v0.5.0...v0.5.1))
86
+ -------------------
76
87
  **Note: Yanked 2011-09-12 because the MultiJSON-patch had a crucial bug**
77
88
 
78
89
  * Fix for invalid gemspec dependency string (see https://github.com/colszowka/simplecov/pull/70,
@@ -82,8 +93,8 @@ v0.5.1 (2011-09-12)
82
93
  is unavailable (see https://github.com/colszowka/simplecov/issues/72
83
94
  and https://github.com/colszowka/simplecov/pull/74, thanks @sferik)
84
95
 
85
- v0.5.0 (2011-09-09)
86
- ===================
96
+ v0.5.0, 2011-09-09 ([changes](https://github.com/colszowka/simplecov/compare/v0.4.2...v0.5.4))
97
+ -------------------
87
98
  **Note: Yanked 2011-09-09 because of trouble with the gemspec.**
88
99
 
89
100
  * JSON is now used instead of YAML for resultset caching (used for merging). Should resolve
@@ -122,10 +133,9 @@ v0.5.0 (2011-09-09)
122
133
 
123
134
  * Full compatibility with Ruby 1.9.3.preview1
124
135
 
125
- HTML Formatter:
126
- ---------------
136
+ ### HTML Formatter:
127
137
 
128
138
  * The display of source files has been improved a lot. Weird scrolling trouble, out-of-scope line hit counts
129
139
  and such should be a thing of the past. Also, it is prettier now.
130
140
  * Source files are now syntax highlighted
131
- * File paths no longer have that annoying './' in front of them
141
+ * File paths no longer have that annoying './' in front of them
data/README.md CHANGED
@@ -7,7 +7,6 @@ SimpleCov [![Build Status](https://secure.travis-ci.org/colszowka/simplecov.png)
7
7
  * [Changelog]
8
8
  * [Rubygem]
9
9
  * [Continuous Integration]
10
- * IRC #simplecov on Freenode
11
10
 
12
11
  [Coverage]: http://www.ruby-doc.org/ruby-1.9/classes/Coverage.html "API doc for Ruby 1.9's Coverage library"
13
12
  [Source Code]: https://github.com/colszowka/simplecov "Source Code @ GitHub"
@@ -470,9 +469,7 @@ If you want to contribute, please:
470
469
 
471
470
  ## Kudos
472
471
 
473
- Thanks to Aaron Patterson (http://engineering.attinteractive.com/2010/08/code-coverage-in-ruby-1-9/) for the original idea
474
- for this!
475
-
472
+ Thanks to Aaron Patterson for the original idea for this!
476
473
 
477
474
  ## Copyright
478
475
 
data/Rakefile CHANGED
@@ -10,6 +10,7 @@ Rake::TestTask.new(:test) do |test|
10
10
  test.libs << 'lib' << 'test'
11
11
  test.test_files = FileList['test/test_*.rb']
12
12
  test.verbose = true
13
+ test.warning = true
13
14
  end
14
15
 
15
16
  require 'cucumber/rake/task'
data/lib/simplecov.rb CHANGED
@@ -48,7 +48,7 @@ module SimpleCov
48
48
  SimpleCov::ResultMerger.store_result(@result) if @result
49
49
  return SimpleCov::ResultMerger.merged_result
50
50
  else
51
- return @result
51
+ return @result if defined? @result
52
52
  end
53
53
  ensure
54
54
  self.running = false
@@ -14,7 +14,7 @@ module SimpleCov::Configuration
14
14
  # Configure with SimpleCov.root('/my/project/path')
15
15
  #
16
16
  def root(root=nil)
17
- return @root if @root and root.nil?
17
+ return @root if defined? @root and root.nil?
18
18
  @root = File.expand_path(root || Dir.getwd)
19
19
  end
20
20
 
@@ -24,7 +24,7 @@ module SimpleCov::Configuration
24
24
  # Configure with SimpleCov.coverage_dir('cov')
25
25
  #
26
26
  def coverage_dir(dir=nil)
27
- return @coverage_dir if @coverage_dir and dir.nil?
27
+ return @coverage_dir if defined? @coverage_dir and dir.nil?
28
28
  @coverage_dir = (dir || 'coverage')
29
29
  end
30
30
 
@@ -67,7 +67,7 @@ module SimpleCov::Configuration
67
67
  # Configure with: SimpleCov.formatter(SimpleCov::Formatter::SimpleFormatter)
68
68
  #
69
69
  def formatter(formatter=nil)
70
- return @formatter if @formatter and formatter.nil?
70
+ return @formatter if defined? @formatter and formatter.nil?
71
71
  @formatter = formatter
72
72
  raise "No formatter configured. Please specify a formatter using SimpleCov.formatter = SimpleCov::Formatter::SimpleFormatter" unless @formatter
73
73
  @formatter
@@ -81,7 +81,7 @@ module SimpleCov::Configuration
81
81
  # Configure with SimpleCov.nocov_token('skip') or it's alias SimpleCov.skip_token('skip')
82
82
  #
83
83
  def nocov_token(nocov_token=nil)
84
- return @nocov_token if @nocov_token and nocov_token.nil?
84
+ return @nocov_token if defined? @nocov_token and nocov_token.nil?
85
85
  @nocov_token = (nocov_token || 'nocov')
86
86
  end
87
87
  alias_method :skip_token, :nocov_token
@@ -44,6 +44,7 @@ module SimpleCov
44
44
 
45
45
  # The multiple of coverage for this result
46
46
  def covered_strength
47
+ return 0 if total_lines.zero?
47
48
  return @covered_strength if @covered_strength
48
49
  m = 0
49
50
  @files.each do |file|
@@ -58,7 +59,7 @@ module SimpleCov
58
59
 
59
60
  # Returns the count of lines that are covered
60
61
  def covered_lines
61
- return @covered_lines if @covered_lines
62
+ return @covered_lines if defined? @covered_lines
62
63
  @covered_lines = 0
63
64
  @files.each do |file|
64
65
  original_result[file.filename].each do |line_result|
@@ -70,7 +71,7 @@ module SimpleCov
70
71
 
71
72
  # Returns the count of missed lines
72
73
  def missed_lines
73
- return @missed_lines if @missed_lines
74
+ return @missed_lines if defined? @missed_lines
74
75
  @missed_lines = 0
75
76
  @files.each do |file|
76
77
  original_result[file.filename].each do |line_result|
@@ -30,6 +30,7 @@ module SimpleCov
30
30
  raise ArgumentError, "Only Fixnum and nil accepted for coverage" unless coverage.kind_of?(Fixnum) or coverage.nil?
31
31
  @src, @line_number, @coverage = src, line_number, coverage
32
32
  @skipped = false
33
+ @src.encode!('UTF-8', 'UTF-8', :invalid => :replace) if @src.respond_to?(:encode!)
33
34
  end
34
35
 
35
36
  # Returns true if this is a line that should have been covered, but was not
@@ -84,7 +85,7 @@ module SimpleCov
84
85
  # Returns all source lines for this file as instances of SimpleCov::SourceFile::Line,
85
86
  # and thus including coverage data. Aliased as :source_lines
86
87
  def lines
87
- return @lines unless @lines.nil?
88
+ return @lines if defined? @lines
88
89
 
89
90
  # Warning to identify condition from Issue #56
90
91
  if coverage.size > src.size
@@ -109,18 +110,30 @@ module SimpleCov
109
110
  # The coverage for this file in percent. 0 if the file has no relevant lines
110
111
  def covered_percent
111
112
  return 100.0 if lines.length == 0 or lines.length == never_lines.count
112
- (covered_lines.count) * 100 / (lines.count - never_lines.count - skipped_lines.count).to_f
113
+ relevant_lines = lines.count - never_lines.count - skipped_lines.count
114
+ if relevant_lines == 0
115
+ 0
116
+ else
117
+ (covered_lines.count) * 100 / relevant_lines.to_f
118
+ end
113
119
  end
114
120
 
115
121
  def covered_strength
116
122
  return 0 if lines.length == 0 or lines.length == never_lines.count
123
+
117
124
  lines_strength = 0
118
125
  lines.each do |c|
119
126
  lines_strength += c.coverage if c.coverage
120
127
  end
128
+
121
129
  effective_lines_count = (lines.count - never_lines.count - skipped_lines.count).to_f
122
- strength = lines_strength / effective_lines_count
123
- round_float(strength, 1)
130
+
131
+ if effective_lines_count == 0
132
+ 0
133
+ else
134
+ strength = lines_strength / effective_lines_count
135
+ round_float(strength, 1)
136
+ end
124
137
  end
125
138
 
126
139
  # Returns all covered lines as SimpleCov::SourceFile::Line
@@ -172,3 +185,4 @@ module SimpleCov
172
185
  end
173
186
  end
174
187
  end
188
+
@@ -1,3 +1,3 @@
1
1
  module SimpleCov
2
- VERSION = "0.6.3"
2
+ VERSION = "0.6.4"
3
3
  end
@@ -0,0 +1,3 @@
1
+
2
+ # localized to Espa�ol thus:
3
+
@@ -68,7 +68,7 @@ class TestSourceFile < Test::Unit::TestCase
68
68
  @source_file.lines
69
69
  end
70
70
 
71
- assert_match /^Warning: coverage data provided/, captured_output
71
+ assert_match(/^Warning: coverage data provided/, captured_output)
72
72
  end
73
73
  end
74
74
 
@@ -80,7 +80,16 @@ class TestSourceFile < Test::Unit::TestCase
80
80
  source_file.process_skipped_lines!
81
81
  end
82
82
  end
83
+
84
+ should "handle iso-8859 encoded source files" do
85
+ source_file = SimpleCov::SourceFile.new(source_fixture('iso-8859.rb'), [nil, nil, 1])
86
+
87
+ assert_nothing_raised do
88
+ source_file.process_skipped_lines!
89
+ end
90
+ end
83
91
  end
84
92
 
85
93
  end
86
94
  end
95
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simplecov
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.3
4
+ version: 0.6.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-05-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: multi_json
16
- requirement: &70307285759020 !ruby/object:Gem::Requirement
16
+ requirement: &70152796757480 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '1.0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70307285759020
24
+ version_requirements: *70152796757480
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: simplecov-html
27
- requirement: &70307285773100 !ruby/object:Gem::Requirement
27
+ requirement: &70152796756780 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 0.5.3
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70307285773100
35
+ version_requirements: *70152796756780
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: aruba
38
- requirement: &70307285790800 !ruby/object:Gem::Requirement
38
+ requirement: &70152796756220 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70307285790800
46
+ version_requirements: *70152796756220
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: capybara
49
- requirement: &70307285820920 !ruby/object:Gem::Requirement
49
+ requirement: &70152796755580 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70307285820920
57
+ version_requirements: *70152796755580
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: appraisal
60
- requirement: &70307285819640 !ruby/object:Gem::Requirement
60
+ requirement: &70152796755020 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70307285819640
68
+ version_requirements: *70152796755020
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: cucumber
71
- requirement: &70307285818160 !ruby/object:Gem::Requirement
71
+ requirement: &70152796754340 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: 1.1.4
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70307285818160
79
+ version_requirements: *70152796754340
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: rake
82
- requirement: &70307285815960 !ruby/object:Gem::Requirement
82
+ requirement: &70152796769980 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: '0'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *70307285815960
90
+ version_requirements: *70152796769980
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: rspec
93
- requirement: &70307285831700 !ruby/object:Gem::Requirement
93
+ requirement: &70152796769100 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: '0'
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *70307285831700
101
+ version_requirements: *70152796769100
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: shoulda
104
- requirement: &70307285827880 !ruby/object:Gem::Requirement
104
+ requirement: &70152796768260 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ! '>='
@@ -109,7 +109,7 @@ dependencies:
109
109
  version: '0'
110
110
  type: :development
111
111
  prerelease: false
112
- version_requirements: *70307285827880
112
+ version_requirements: *70152796768260
113
113
  description: Code coverage for Ruby 1.9 with a powerful configuration library and
114
114
  automatic merging of coverage across test suites
115
115
  email:
@@ -119,7 +119,6 @@ extensions: []
119
119
  extra_rdoc_files: []
120
120
  files:
121
121
  - .gitignore
122
- - .rvmrc
123
122
  - .travis.yml
124
123
  - Appraisals
125
124
  - CHANGELOG.md
@@ -203,6 +202,7 @@ files:
203
202
  - test/fixtures/frameworks/rspec_good.rb
204
203
  - test/fixtures/frameworks/testunit_bad.rb
205
204
  - test/fixtures/frameworks/testunit_good.rb
205
+ - test/fixtures/iso-8859.rb
206
206
  - test/fixtures/resultset1.rb
207
207
  - test/fixtures/resultset2.rb
208
208
  - test/fixtures/sample.rb
@@ -233,7 +233,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
233
233
  version: '0'
234
234
  segments:
235
235
  - 0
236
- hash: 4064525278113991582
236
+ hash: 1802100492995601719
237
237
  required_rubygems_version: !ruby/object:Gem::Requirement
238
238
  none: false
239
239
  requirements:
@@ -242,7 +242,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
242
242
  version: '0'
243
243
  segments:
244
244
  - 0
245
- hash: 4064525278113991582
245
+ hash: 1802100492995601719
246
246
  requirements: []
247
247
  rubyforge_project:
248
248
  rubygems_version: 1.8.16
@@ -305,6 +305,7 @@ test_files:
305
305
  - test/fixtures/frameworks/rspec_good.rb
306
306
  - test/fixtures/frameworks/testunit_bad.rb
307
307
  - test/fixtures/frameworks/testunit_good.rb
308
+ - test/fixtures/iso-8859.rb
308
309
  - test/fixtures/resultset1.rb
309
310
  - test/fixtures/resultset2.rb
310
311
  - test/fixtures/sample.rb
data/.rvmrc DELETED
@@ -1 +0,0 @@
1
- rvm use 1.9.3-p125