simplecov-console 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +45 -1
- data/VERSION +1 -1
- data/lib/simplecov-console.rb +47 -24
- data/simplecov-console.gemspec +3 -3
- data/test/test_simplecov-console.rb +33 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 598ac9ff4a2aab65354e06424d3e33647cb2ffc94acef55e41c06dacc770b4cc
|
4
|
+
data.tar.gz: de3d31bc67c9e295710911f0c8d0fdc1edd23c1784c48416bcaf481c3b58095b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 404d96b20f0dfb5abf1b1004738fdaa1675514f780f5bca0e89396feecdd9a2c1ed8032cecf2810b15ed3abc442a75b617f9c476c4bd8831bf32e7d725169c42
|
7
|
+
data.tar.gz: 57d40a7ddb72a87e1f561209f67021cf49f5bd4ed016da026c15ebae43aaea16594a3e21069cc894a4fd3f36066380e55fe42096d41b56743b1f69dc28174a88
|
data/README.md
CHANGED
@@ -91,8 +91,52 @@ SimpleCov::Formatter::Console.table_options = {:style => {:width => 200}}
|
|
91
91
|
SimpleCov.formatter = SimpleCov::Formatter::Console
|
92
92
|
```
|
93
93
|
|
94
|
+
### Block output style
|
95
|
+
|
96
|
+
As an alternative to the default table output format, results can be printed as plain text blocks instead by setting
|
97
|
+
the formatter `output_style` to 'block':
|
98
|
+
|
99
|
+
```ruby
|
100
|
+
SimpleCov::Formatter::Console.output_style = 'block'
|
101
|
+
SimpleCov.formatter = SimpleCov::Formatter::Console
|
102
|
+
```
|
103
|
+
|
104
|
+
Example output:
|
105
|
+
|
106
|
+
```text
|
107
|
+
COVERAGE: 82.34% -- 2345/2848 lines in 111 files
|
108
|
+
|
109
|
+
showing bottom (worst) 5 of 69 files
|
110
|
+
|
111
|
+
file: lib/bixby/api/websocket_server.rb
|
112
|
+
coverage: 22.73% (17/22 lines)
|
113
|
+
missed: 11, 14, 17-18, 20-22, 24, 28-30, 32, 36-...
|
114
|
+
|
115
|
+
file: app/models/role.rb
|
116
|
+
coverage: 30.77% (9/13 lines)
|
117
|
+
missed: 28-34, 36-37
|
118
|
+
|
119
|
+
file: lib/bixby/modules/metrics/rescan.rb
|
120
|
+
coverage: 32.14% (19/28 lines)
|
121
|
+
missed: 19-23, 27-31, 33-37, 39-41, 43
|
122
|
+
|
123
|
+
file: lib/archie/mail.rb
|
124
|
+
coverage: 42.86% (8/14 lines)
|
125
|
+
missed: 6-8, 12-15, 22
|
126
|
+
|
127
|
+
file: lib/archie/controller.rb
|
128
|
+
coverage: 44.00% (28/50 lines)
|
129
|
+
missed: 18-21, 23, 27-30, 32, 38-40, 44-45, 48-4...
|
130
|
+
|
131
|
+
42 file(s) with 100% coverage not shown
|
132
|
+
```
|
133
|
+
|
94
134
|
## History
|
95
135
|
|
136
|
+
### 0.7 (2020.03.04)
|
137
|
+
|
138
|
+
- Added new 'block' style output option - thanks [@hpainter](https://github.com/hpainter)! ([#15](https://github.com/chetan/simplecov-console/issues/15))
|
139
|
+
|
96
140
|
### 0.6 (2019.11.08)
|
97
141
|
|
98
142
|
- Added new config options: `sort`, `show_covered`, and `max_rows`
|
@@ -114,5 +158,5 @@ SimpleCov.formatter = SimpleCov::Formatter::Console
|
|
114
158
|
|
115
159
|
### Copyright
|
116
160
|
|
117
|
-
Copyright (c)
|
161
|
+
Copyright (c) 2020 Chetan Sarva. See LICENSE.txt for
|
118
162
|
further details.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.7.0
|
data/lib/simplecov-console.rb
CHANGED
@@ -5,7 +5,7 @@ class SimpleCov::Formatter::Console
|
|
5
5
|
|
6
6
|
VERSION = IO.read(File.expand_path("../../VERSION", __FILE__)).strip
|
7
7
|
|
8
|
-
ATTRIBUTES = [:table_options, :use_colors, :max_rows, :show_covered, :sort]
|
8
|
+
ATTRIBUTES = [:table_options, :use_colors, :max_rows, :show_covered, :sort, :output_style]
|
9
9
|
class << self
|
10
10
|
attr_accessor(*ATTRIBUTES)
|
11
11
|
end
|
@@ -23,6 +23,9 @@ class SimpleCov::Formatter::Console
|
|
23
23
|
# configure sort from SORT env var
|
24
24
|
SimpleCov::Formatter::Console.sort = ENV.fetch('SORT', 'coverage')
|
25
25
|
|
26
|
+
# configure output format ('table', 'block')
|
27
|
+
SimpleCov::Formatter::Console.output_style = ENV.fetch('OUTPUT_STYLE', 'table')
|
28
|
+
|
26
29
|
def format(result)
|
27
30
|
|
28
31
|
root = nil
|
@@ -66,33 +69,15 @@ class SimpleCov::Formatter::Console
|
|
66
69
|
end
|
67
70
|
end
|
68
71
|
|
69
|
-
table = files.map do |f|
|
70
|
-
[
|
71
|
-
colorize(pct(f)),
|
72
|
-
f.filename.gsub(root + "/", ''),
|
73
|
-
f.lines_of_code,
|
74
|
-
f.missed_lines.count,
|
75
|
-
missed(f.missed_lines).join(", ")
|
76
|
-
]
|
77
|
-
end
|
78
|
-
|
79
72
|
max_rows = SimpleCov::Formatter::Console.max_rows
|
80
73
|
|
81
|
-
if ![-1, nil].include?(max_rows) &&
|
82
|
-
puts "showing bottom (worst) #{max_rows} of #{
|
83
|
-
|
74
|
+
if ![-1, nil].include?(max_rows) && files.size > max_rows then
|
75
|
+
puts "showing bottom (worst) #{max_rows} of #{files.size} files"
|
76
|
+
files = files.slice(0, max_rows)
|
84
77
|
end
|
85
78
|
|
86
|
-
|
87
|
-
|
88
|
-
raise ArgumentError.new("SimpleCov::Formatter::Console.table_options must be a Hash")
|
89
|
-
end
|
90
|
-
headings = %w{ coverage file lines missed missing }
|
91
|
-
|
92
|
-
opts = table_options.merge({:headings => headings, :rows => table})
|
93
|
-
t = Terminal::Table.new(opts)
|
94
|
-
puts t
|
95
|
-
|
79
|
+
puts send(SimpleCov::Formatter::Console.output_style << "_output",files,root)
|
80
|
+
|
96
81
|
if covered_files > 0 then
|
97
82
|
puts "#{covered_files} file(s) with 100% coverage not shown"
|
98
83
|
end
|
@@ -149,4 +134,42 @@ class SimpleCov::Formatter::Console
|
|
149
134
|
end
|
150
135
|
end
|
151
136
|
|
137
|
+
# format per-file results output using Terminal::Table
|
138
|
+
def table_output(files, root)
|
139
|
+
table = files.map do |f|
|
140
|
+
[
|
141
|
+
colorize(pct(f)),
|
142
|
+
f.filename.gsub(root + "/", ''),
|
143
|
+
f.lines_of_code,
|
144
|
+
f.missed_lines.count,
|
145
|
+
missed(f.missed_lines).join(", ")
|
146
|
+
]
|
147
|
+
end
|
148
|
+
|
149
|
+
table_options = SimpleCov::Formatter::Console.table_options || {}
|
150
|
+
if !table_options.kind_of?(Hash) then
|
151
|
+
raise ArgumentError.new("SimpleCov::Formatter::Console.table_options must be a Hash")
|
152
|
+
end
|
153
|
+
|
154
|
+
headings = %w{ coverage file lines missed missing }
|
155
|
+
|
156
|
+
opts = table_options.merge({:headings => headings, :rows => table})
|
157
|
+
Terminal::Table.new(opts)
|
158
|
+
end
|
159
|
+
|
160
|
+
# format per-file results output as plain text blocks
|
161
|
+
def block_output(files, root)
|
162
|
+
blocks = []
|
163
|
+
files.each do |f|
|
164
|
+
block = []
|
165
|
+
block << sprintf("%8.8s: %s", 'file', f.filename.gsub(root + "/", ''))
|
166
|
+
block << sprintf("%8.8s: %s (%d/%d lines)", 'coverage',
|
167
|
+
colorize(sprintf("%.2f%%", f.covered_percent)),
|
168
|
+
f.covered_lines.count, f.lines_of_code)
|
169
|
+
block << sprintf("%8.8s: %s", 'missed', missed(f.missed_lines).join(", "))
|
170
|
+
blocks << block.join("\n")
|
171
|
+
end
|
172
|
+
"\n" << blocks.join("\n\n") << "\n\n"
|
173
|
+
end
|
174
|
+
|
152
175
|
end
|
data/simplecov-console.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: simplecov-console 0.
|
5
|
+
# stub: simplecov-console 0.7.0 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "simplecov-console".freeze
|
9
|
-
s.version = "0.
|
9
|
+
s.version = "0.7.0"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib".freeze]
|
13
13
|
s.authors = ["Chetan Sarva".freeze]
|
14
|
-
s.date = "
|
14
|
+
s.date = "2020-03-03"
|
15
15
|
s.description = "Simple console output formatter for SimpleCov".freeze
|
16
16
|
s.email = "chetan@pixelcop.net".freeze
|
17
17
|
s.extra_rdoc_files = [
|
@@ -2,7 +2,17 @@ require 'helper'
|
|
2
2
|
|
3
3
|
class TestSimplecovConsole < MiniTest::Test
|
4
4
|
|
5
|
-
|
5
|
+
# mock for SimpleCov::SourceFile::Line
|
6
|
+
Line = Struct.new(:line_number)
|
7
|
+
|
8
|
+
# mock for SimpleCov::SourceFile
|
9
|
+
SourceFile = Struct.new(
|
10
|
+
:filename,
|
11
|
+
:lines_of_code,
|
12
|
+
:covered_lines,
|
13
|
+
:missed_lines,
|
14
|
+
:covered_percent
|
15
|
+
)
|
6
16
|
|
7
17
|
def setup
|
8
18
|
@console = SimpleCov::Formatter::Console.new
|
@@ -14,9 +24,29 @@ class TestSimplecovConsole < MiniTest::Test
|
|
14
24
|
end
|
15
25
|
|
16
26
|
def test_missed
|
17
|
-
missed_lines = [
|
18
|
-
|
27
|
+
missed_lines = [Line.new(1), Line.new(2),
|
28
|
+
Line.new(3), Line.new(5)]
|
19
29
|
expected_result = ["1-3", "5"]
|
20
30
|
assert_equal @console.missed(missed_lines), expected_result
|
21
31
|
end
|
32
|
+
|
33
|
+
def test_table_output
|
34
|
+
SimpleCov::Formatter::Console.output_style = 'table'
|
35
|
+
files = [
|
36
|
+
SourceFile.new('foo.rb',5,[2,3],[Line.new(1), Line.new(4), Line.new(5)],40.0)
|
37
|
+
]
|
38
|
+
actual = @console.table_output(files,'/')
|
39
|
+
assert actual.is_a? Terminal::Table
|
40
|
+
assert_equal 1, actual.rows.count
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_block_output
|
44
|
+
SimpleCov::Formatter::Console.use_colors = false
|
45
|
+
SimpleCov::Formatter::Console.output_style = 'block'
|
46
|
+
files = [
|
47
|
+
SourceFile.new('foo.rb',5,[2,3],[Line.new(1), Line.new(4), Line.new(5)],40.0)
|
48
|
+
]
|
49
|
+
expected = "\n file: foo.rb\ncoverage: 40.00% (2/5 lines)\n missed: 1, 4-5\n\n"
|
50
|
+
assert_equal expected, @console.block_output(files,'/')
|
51
|
+
end
|
22
52
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simplecov-console
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chetan Sarva
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-03-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: simplecov
|