covered 0.20.1 → 0.21.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2a1eaf5277a7fb0e714337382c57b984cac7f85ca1dcf554bad14aa854fa83c5
4
- data.tar.gz: 0ffef4a5eca5b677089d094aff7d6ad566a7fa5a6790ca64199a5411a0c08c16
3
+ metadata.gz: f81a87dfa60bac921785b65464dac44223ea3a449fc4701e205dd0f8d8bfece0
4
+ data.tar.gz: 7812cbe1c1622620bcc2b8dfcc70e9a97eda3cbb84dc5bea7291ce62009f5ec6
5
5
  SHA512:
6
- metadata.gz: 505bac20e09538f38461bf9aecc016ada76557d1f60d1f0cdb4b4279d5505b556f23bdf10d2944f76e410f14cf32a8925e790c6e7ee5756f465169d78184b3f1
7
- data.tar.gz: ae1294f4a3833a2394b5a7239c9a044f9bb2208d2e0b96db774cd508413eb092f46b2ab5891418803add487e0e6ee3dd033948c9161201a028f71b42dfe8d910
6
+ metadata.gz: 93b23c3c8ceecffbfb48d1739d0d4fc039f9e0ac90037f0414fb0ee660509d003d52e3618d3bc6ef6151ef4161e81de95e96c780868bac016ad1e7c4fe4ab709
7
+ data.tar.gz: e933d87ab654a06c99e11ea505c520ed89f60741241dc18246dca8fb6ff7266c3ddb5fa1b47c45f246de2cc5cd1325d165767a31e5e8ec63e57835138e2b6297
checksums.yaml.gz.sig CHANGED
Binary file
@@ -21,15 +21,26 @@ module Covered
21
21
  ::Coverage.result(stop: false, clear: true)
22
22
  end
23
23
 
24
+ EVAL_PATHS = {
25
+ "(eval)" => true,
26
+ "(irb)" => true,
27
+ "eval" => true
28
+ }
29
+
24
30
  def finish
25
31
  results = ::Coverage.result
26
32
 
27
33
  results.each do |path, result|
28
- lines = result[:lines]
34
+ next if EVAL_PATHS.include?(path)
35
+
29
36
  path = self.expand_path(path)
30
37
 
31
- lines.each_with_index do |count, lineno|
32
- @output.mark(path, lineno+1, count) if count
38
+ # Skip files which don't exist. This can happen if `eval` is used with an invalid/incorrect path.
39
+ if File.exist?(path)
40
+ @output.mark(path, 1, result[:lines])
41
+ else
42
+ # warn "Skipping coverage for #{path.inspect} because it doesn't exist!"
43
+ # Ignore.
33
44
  end
34
45
  end
35
46
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2022-2023, by Samuel Williams.
4
+ # Copyright, 2019-2023, by Samuel Williams.
5
5
 
6
6
  require_relative 'policy'
7
7
 
data/lib/covered/files.rb CHANGED
@@ -34,10 +34,15 @@ module Covered
34
34
  end
35
35
 
36
36
  def mark(lineno, value = 1)
37
- if @counts[lineno]
38
- @counts[lineno] += value
39
- else
40
- @counts[lineno] = value
37
+ # As currently implemented, @counts is base-zero rather than base-one.
38
+ # Line numbers generally start at line 1, so the first line, line 1, is at index 1. This means that index[0] is usually nil.
39
+ Array(value).each_with_index do |value, index|
40
+ offset = lineno + index
41
+ if @counts[offset]
42
+ @counts[offset] += value
43
+ else
44
+ @counts[offset] = value
45
+ end
41
46
  end
42
47
  end
43
48
 
@@ -29,6 +29,7 @@ module Covered
29
29
  terminal[:ignored_code] ||= terminal.style(nil, nil, :faint)
30
30
 
31
31
  terminal[:annotations] ||= terminal.style(:blue)
32
+ terminal[:error] ||= terminal.style(:red)
32
33
  end
33
34
  end
34
35
 
@@ -82,36 +83,49 @@ module Covered
82
83
  end
83
84
  end
84
85
 
86
+ def print_coverage(terminal, coverage)
87
+ line_offset = 1
88
+ counts = coverage.counts
89
+
90
+ coverage.read do |file|
91
+ print_line_header(terminal)
92
+
93
+ file.each_line do |line|
94
+ count = counts[line_offset]
95
+
96
+ print_annotations(terminal, coverage, line, line_offset)
97
+
98
+ print_line(terminal, line, line_offset, count)
99
+
100
+ line_offset += 1
101
+ end
102
+ end
103
+ end
104
+
105
+ def print_error(terminal, error)
106
+ terminal.puts "Error: #{error.message}", style: :error
107
+ terminal.puts error.backtrace
108
+ end
109
+
85
110
  # A coverage array gives, for each line, the number of line execution by the interpreter. A nil value means coverage is finishd for this line (lines like else and end).
86
- def call(wrapper, output = $stdout)
111
+ def call(wrapper, output = $stdout, **options)
87
112
  terminal = self.terminal(output)
88
113
 
89
114
  statistics = self.each(wrapper) do |coverage|
90
- line_offset = 1
91
-
92
115
  path = wrapper.relative_path(coverage.path)
93
116
  terminal.puts ""
94
117
  terminal.puts path, style: :path
95
118
 
96
- counts = coverage.counts
97
-
98
- coverage.read do |file|
99
- print_line_header(terminal)
100
-
101
- file.each_line do |line|
102
- count = counts[line_offset]
103
-
104
- print_annotations(terminal, coverage, line, line_offset)
105
-
106
- print_line(terminal, line, line_offset, count)
107
-
108
- line_offset += 1
109
- end
119
+ begin
120
+ print_coverage(terminal, coverage, **options)
121
+ rescue => error
122
+ print_error(terminal, error)
110
123
  end
111
124
 
112
125
  coverage.print(output)
113
126
  end
114
127
 
128
+ terminal.puts
115
129
  statistics.print(output)
116
130
  end
117
131
  end
@@ -150,49 +164,35 @@ module Covered
150
164
  end
151
165
 
152
166
  class PartialSummary < Summary
153
- def call(wrapper, output = $stdout, before: 4, after: 4)
154
- terminal = self.terminal(output)
167
+ def print_coverage(terminal, coverage, before: 4, after: 4)
168
+ return if coverage.zero?
155
169
 
156
- statistics = self.each(wrapper) do |coverage|
157
- line_offset = 1
158
-
159
- path = wrapper.relative_path(coverage.path)
160
- terminal.puts ""
161
- terminal.puts path, style: :path
162
-
163
- counts = coverage.counts
164
- last_line = nil
170
+ line_offset = 1
171
+ counts = coverage.counts
172
+ last_line = nil
173
+
174
+ coverage.read do |file|
175
+ print_line_header(terminal)
165
176
 
166
- unless coverage.zero?
167
- print_line_header(terminal)
177
+ file.each_line do |line|
178
+ range = Range.new([line_offset - before, 0].max, line_offset+after)
168
179
 
169
- coverage.read do |file|
170
- file.each_line do |line|
171
- range = Range.new([line_offset - before, 0].max, line_offset+after)
172
-
173
- if counts[range]&.include?(0)
174
- count = counts[line_offset]
175
-
176
- if last_line and last_line != line_offset-1
177
- terminal.puts ":".rjust(16)
178
- end
179
-
180
- print_annotations(terminal, coverage, line, line_offset)
181
- print_line(terminal, line, line_offset, count)
182
-
183
- last_line = line_offset
184
- end
185
-
186
- line_offset += 1
180
+ if counts[range]&.include?(0)
181
+ count = counts[line_offset]
182
+
183
+ if last_line and last_line != line_offset-1
184
+ terminal.puts ":".rjust(16)
187
185
  end
186
+
187
+ print_annotations(terminal, coverage, line, line_offset)
188
+ print_line(terminal, line, line_offset, count)
189
+
190
+ last_line = line_offset
188
191
  end
192
+
193
+ line_offset += 1
189
194
  end
190
-
191
- coverage.print(output)
192
195
  end
193
-
194
- terminal.puts
195
- statistics.print(output)
196
196
  end
197
197
  end
198
198
 
data/lib/covered/sus.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2022-2023, by Samuel Williams.
4
+ # Copyright, 2019-2023, by Samuel Williams.
5
5
 
6
6
  module Covered
7
7
  module Sus
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2018-2022, by Samuel Williams.
4
+ # Copyright, 2018-2023, by Samuel Williams.
5
5
 
6
6
  module Covered
7
- VERSION = "0.20.1"
7
+ VERSION = "0.21.0"
8
8
  end
data/license.md CHANGED
@@ -2,7 +2,6 @@
2
2
 
3
3
  Copyright, 2018-2023, by Samuel Williams.
4
4
  Copyright, 2018, by Shannon Skipper.
5
- Copyright, 2018, by chocolateboy.
6
5
  Copyright, 2019, by Cyril Roelandt.
7
6
  Copyright, 2022, by Adam Daniels.
8
7
  Copyright, 2022, by Felix Yan.
data/readme.md CHANGED
@@ -61,6 +61,10 @@ When running `rspec`, you can specify the kind of coverage analysis you would li
61
61
 
62
62
  If no `COVERAGE` is specified, coverage tracking will be finishd.
63
63
 
64
+ ### Template Coverage
65
+
66
+ Covered supports coverage of templates which are compiled into Ruby code. This is only supported on Ruby 3.2+ due to enhancements in the coverage interface.
67
+
64
68
  ### Partial Summary
65
69
 
66
70
  COVERAGE=PartialSummary rspec
@@ -73,17 +77,6 @@ This report only shows snippets of source code with incomplete coverage.
73
77
 
74
78
  This report lists several files in order of least coverage.l
75
79
 
76
- ### Coveralls/Travis Integration
77
-
78
- You can send coverage information to [Coveralls](https://coveralls.io) by editing your `.travis.yml` file:
79
-
80
- matrix:
81
- include:
82
- - rvm: 2.6
83
- env: COVERAGE=PartialSummary,Coveralls
84
-
85
- This will print out a brief report and then upload the coverage data. This integrates transparently with Travis.
86
-
87
80
  ## See Also
88
81
 
89
82
  - [coveralls-ruby](https://github.com/lemurheavy/coveralls-ruby) – the official Coveralls implementation for Ruby.
@@ -91,32 +84,18 @@ This will print out a brief report and then upload the coverage data. This integ
91
84
 
92
85
  ## Contributing
93
86
 
94
- 1. Fork it
95
- 2. Create your feature branch (`git checkout -b my-new-feature`)
96
- 3. Commit your changes (`git commit -am 'Add some feature'`)
97
- 4. Push to the branch (`git push origin my-new-feature`)
98
- 5. Create new Pull Request
99
-
100
- ## License
87
+ We welcome contributions to this project.
101
88
 
102
- Released under the MIT license.
89
+ 1. Fork it.
90
+ 2. Create your feature branch (`git checkout -b my-new-feature`).
91
+ 3. Commit your changes (`git commit -am 'Add some feature'`).
92
+ 4. Push to the branch (`git push origin my-new-feature`).
93
+ 5. Create new Pull Request.
103
94
 
104
- Copyright, 2018, by [Samuel G. D. Williams](http://www.codeotaku.com/samuel-williams).
95
+ ### Developer Certificate of Origin
105
96
 
106
- Permission is hereby granted, free of charge, to any person obtaining a copy
107
- of this software and associated documentation files (the "Software"), to deal
108
- in the Software without restriction, including without limitation the rights
109
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
110
- copies of the Software, and to permit persons to whom the Software is
111
- furnished to do so, subject to the following conditions:
97
+ This project uses the [Developer Certificate of Origin](https://developercertificate.org/). All contributors to this project must agree to this document to have their contributions accepted.
112
98
 
113
- The above copyright notice and this permission notice shall be included in
114
- all copies or substantial portions of the Software.
99
+ ### Contributor Covenant
115
100
 
116
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
117
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
118
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
119
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
120
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
121
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
122
- THE SOFTWARE.
101
+ This project is governed by [Contributor Covenant](https://www.contributor-covenant.org/). All contributors and participants agree to abide by its terms.
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: covered
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.20.1
4
+ version: 0.21.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -10,7 +10,6 @@ authors:
10
10
  - Felix Yan
11
11
  - Shannon Skipper
12
12
  - Stephen Ierodiaconou
13
- - chocolateboy
14
13
  autorequire:
15
14
  bindir: bin
16
15
  cert_chain:
@@ -43,7 +42,7 @@ cert_chain:
43
42
  Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
44
43
  voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
45
44
  -----END CERTIFICATE-----
46
- date: 2023-02-10 00:00:00.000000000 Z
45
+ date: 2023-06-30 00:00:00.000000000 Z
47
46
  dependencies:
48
47
  - !ruby/object:Gem::Dependency
49
48
  name: console
@@ -73,62 +72,6 @@ dependencies:
73
72
  - - "~>"
74
73
  - !ruby/object:Gem::Version
75
74
  version: '1.0'
76
- - !ruby/object:Gem::Dependency
77
- name: bundler
78
- requirement: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
- type: :development
84
- prerelease: false
85
- version_requirements: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- - !ruby/object:Gem::Dependency
91
- name: rspec
92
- requirement: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: '3.6'
97
- type: :development
98
- prerelease: false
99
- version_requirements: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - "~>"
102
- - !ruby/object:Gem::Version
103
- version: '3.6'
104
- - !ruby/object:Gem::Dependency
105
- name: sus
106
- requirement: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - "~>"
109
- - !ruby/object:Gem::Version
110
- version: '0.14'
111
- type: :development
112
- prerelease: false
113
- version_requirements: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - "~>"
116
- - !ruby/object:Gem::Version
117
- version: '0.14'
118
- - !ruby/object:Gem::Dependency
119
- name: trenni
120
- requirement: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - "~>"
123
- - !ruby/object:Gem::Version
124
- version: '3.6'
125
- type: :development
126
- prerelease: false
127
- version_requirements: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - "~>"
130
- - !ruby/object:Gem::Version
131
- version: '3.6'
132
75
  description:
133
76
  email:
134
77
  executables: []
@@ -169,14 +112,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
169
112
  requirements:
170
113
  - - ">="
171
114
  - !ruby/object:Gem::Version
172
- version: '3.2'
115
+ version: '3.0'
173
116
  required_rubygems_version: !ruby/object:Gem::Requirement
174
117
  requirements:
175
118
  - - ">="
176
119
  - !ruby/object:Gem::Version
177
120
  version: '0'
178
121
  requirements: []
179
- rubygems_version: 3.4.1
122
+ rubygems_version: 3.2.33
180
123
  signing_key:
181
124
  specification_version: 4
182
125
  summary: A modern approach to code coverage.
metadata.gz.sig CHANGED
Binary file