simplecov-console 0.9.4 → 0.9.5

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3a1267b23851a2258f22f2d61dc91e3b4d83d4ccca4a4b5cd55088acdd490555
4
- data.tar.gz: f81eb0ea573d57e201d9a310d0fcff5eba351d499af5bf42519c0f9399a18c33
3
+ metadata.gz: 84f74674ee795a92b2426780fa64273877eab8a17893b015d0c6af9bc69ba5aa
4
+ data.tar.gz: 301d1b39df2e27ac0d1dccce570a0105a2b17b090bef0f6c005ea40df6bcc3f0
5
5
  SHA512:
6
- metadata.gz: ce0da6a41195df38f755027e5573a2a5236c8b1445f2ef41349b4748828a487a8c067115e3a188a48525b1ecc25c1c9079cf6e185c02c6cb26426cc48b59140f
7
- data.tar.gz: 468c6aeb7d79dba8ca66c7e57341f0a02a88a7b39f6a27b47ffd71ca5bd0a623c85196d42d9459abe5f3649e4bc6921808dd93a81240147e10899e00a2969fb9
6
+ metadata.gz: 18eb0f83ee43f731f952d17951a49a4e9027936f605dfcfefb913788f4118dd61a807e74f604bdeafef4e42865d6e30ad452bbd4f6de9c511daacbb0eb52bedd
7
+ data.tar.gz: 64e8281b7cec60f7612dd9047a2d520e842ea24c989142e2b13591c82a5995607f949bc628bb903e933025ab2b5b71ce462764ddd601e917b44b3246403a97ff
data/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.9.5 (2026.02.02)
4
+
5
+ - Feat: added `branch_missing_len` option - thanks [@nialbima](https://github.com/nialbima)! ([#28](https://github.com/chetan/simplecov-console/pull/28))
6
+
7
+ ## 0.9.4 (2025.07.23)
8
+
9
+ - Docs: updated `use_color` info - thanks [@th7](https://github.com/th7)! ([#27](https://github.com/chetan/simplecov-console/pull/27))
10
+
11
+ ## 0.9.3 (2025.02.18)
12
+
13
+ - Added `output_to_file` and `output_filename` options - thanks [@miegs3](https://github.com/miegs3)! ([#26](https://github.com/chetan/simplecov-console/pull/26))
14
+
3
15
  ## 0.9.2 (2024.09.17)
4
16
 
5
17
  - Fix: typo in output ([#24](https://github.com/chetan/simplecov-console/pull/24))
data/README.md CHANGED
@@ -59,6 +59,7 @@ SimpleCov::Formatter::Console.show_covered = true # show all files in coverage r
59
59
  SimpleCov::Formatter::Console.max_rows = 15 # integer
60
60
  SimpleCov::Formatter::Console.max_lines = 5 # integer
61
61
  SimpleCov::Formatter::Console.missing_len = 20 # integer
62
+ SimpleCov::Formatter::Console.branch_missing_len = 0 # integer
62
63
  SimpleCov::Formatter::Console.output_style = 'block' # 'table' (default) or 'block'
63
64
  SimpleCov::Formatter::Console.table_options = {:style => {:width => 200}}
64
65
  SimpleCov::Formatter::Console.output_to_file = false
@@ -205,44 +206,17 @@ BRANCH COVERAGE: 83.33% -- 5/6 branches in 2 branches
205
206
  +----------+-------------------------------+-------+--------+---------------+-----------------+----------+-----------------+------------------+
206
207
  ```
207
208
 
208
- ## History
209
-
210
- ### 0.9.2 (2024.09.17)
211
-
212
- - Fix: typo in output ([#24](https://github.com/chetan/simplecov-console/pull/24))
213
-
214
- ### 0.9.1 (2021.02.01)
215
-
216
- - Fix: Don't add ellipsis if line groups are not truncated - thanks [@lbraun](https://github.com/lbraun)! ([#21](https://github.com/chetan/simplecov-console/pull/21))
217
-
218
- ### 0.9 (2021.01.21)
219
-
220
- - Added support for limiting number of lines shown
221
-
222
- ### 0.8 (2020.11.11)
223
-
224
- - Added support for branch coverage - thanks [@robotdana](https://github.com/robotdana)! ([#19](https://github.com/chetan/simplecov-console/pull/19))
209
+ #### Maximum length of missing branches
225
210
 
226
- ### 0.7.2 (2020.03.05)
211
+ Similar to `missing_len` above, set `branch_missing_len` to truncate long lists of missing branches.
227
212
 
228
- - Fix: table output include ([#17](https://github.com/chetan/simplecov-console/issues/17))
229
-
230
- ### 0.7.1 (2020.03.05)
231
-
232
- - Fix: block output doesn't work with frozen string literal ([#16](https://github.com/chetan/simplecov-console/issues/16))
233
-
234
- ### 0.7 (2020.03.04)
235
-
236
- - Added new 'block' style output option - thanks [@hpainter](https://github.com/hpainter)! ([#15](https://github.com/chetan/simplecov-console/issues/15))
237
-
238
- ### 0.6 (2019.11.08)
239
-
240
- - Added new config options: `sort`, `show_covered`, and `max_rows`
213
+ ```ruby
214
+ SimpleCov::Formatter::Console.branch_missing_len = 10 # integer (default is 0, no limit)
215
+ ```
241
216
 
242
- ### 0.5 (2019.05.24)
217
+ ## History
243
218
 
244
- - Replaced `hirb` gem with `terminal-table` due to multiple warnings thrown ([#11](https://github.com/chetan/simplecov-console/issues/11))
245
- - Support [disabling colorized](https://no-color.org/) output via `NO_COLOR` env var
219
+ See [Changelog](./CHANGELOG.md)
246
220
 
247
221
  ## Contributing
248
222
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.4
1
+ 0.9.5
@@ -16,7 +16,7 @@ class SimpleCov::Formatter::Console
16
16
  block << sprintf("%8.8s: %s (%d/%d branches)", 'branches',
17
17
  colorize(sprintf("%.2f%%", f.coverage_statistics[:branch].percent)),
18
18
  (f.total_branches.count - f.missed_branches.count), f.total_branches.count)
19
- block << sprintf("%8.8s: %s", 'missed', branches_missed(f.missed_branches).join(", "))
19
+ block << sprintf("%8.8s: %s", 'missed', trunc(branches_missed(f.missed_branches).join(", "), type: :branch))
20
20
  end
21
21
  blocks << block.join("\n")
22
22
  end
@@ -18,7 +18,7 @@ class SimpleCov::Formatter::Console
18
18
  colorize(pct(f.coverage_statistics[:branch].percent)),
19
19
  f.total_branches.count,
20
20
  f.missed_branches.count,
21
- branches_missed(f.missed_branches).join(", ")
21
+ trunc(branches_missed(f.missed_branches).join(", "), type: :branch)
22
22
  ]
23
23
  end
24
24
 
@@ -4,8 +4,19 @@ class SimpleCov::Formatter::Console
4
4
 
5
5
  VERSION = IO.read(File.expand_path("../../VERSION", __FILE__)).strip
6
6
 
7
- ATTRIBUTES = [:table_options, :use_colors, :max_rows, :max_lines,
8
- :missing_len, :show_covered, :sort, :output_style, :output_to_file, :output_filename]
7
+ ATTRIBUTES = [
8
+ :branch_missing_len,
9
+ :max_lines,
10
+ :max_rows,
11
+ :missing_len,
12
+ :output_filename,
13
+ :output_style,
14
+ :output_to_file,
15
+ :show_covered,
16
+ :sort,
17
+ :table_options,
18
+ :use_colors,
19
+ ]
9
20
 
10
21
  class << self
11
22
  attr_accessor(*ATTRIBUTES)
@@ -21,6 +32,7 @@ class SimpleCov::Formatter::Console
21
32
  # configure max lines per row and missing len
22
33
  SimpleCov::Formatter::Console.max_lines = ENV.fetch('MAX_LINES', 0).to_i
23
34
  SimpleCov::Formatter::Console.missing_len = ENV.fetch('MISSING_LEN', 0).to_i
35
+ SimpleCov::Formatter::Console.branch_missing_len = ENV.fetch('BRANCH_MISSING_LEN', 0).to_i
24
36
 
25
37
  # configure show_covered from SHOW_COVERED env var
26
38
  SimpleCov::Formatter::Console.show_covered = ENV.fetch('SHOW_COVERED', 'false') == 'true'
@@ -183,12 +195,16 @@ class SimpleCov::Formatter::Console
183
195
  end
184
196
 
185
197
  # Truncate string to at most N chars (as defined by missing_len)
186
- def trunc(str)
198
+ def trunc(str, type: :line)
187
199
  return str if str.include?("...") # already truncated, skip
188
200
 
189
- len = SimpleCov::Formatter::Console.missing_len
190
- if len > 0 && str.size > len then
191
- str = str[0, len].gsub(/,(\s+)?$/, '') + ' ...'
201
+ len = type == :branch ? SimpleCov::Formatter::Console.branch_missing_len : SimpleCov::Formatter::Console.missing_len
202
+ if len > 0 && str.size > len
203
+ truncated = str[0, len]
204
+ if type == :branch && !truncated.end_with?(']')
205
+ truncated = truncated.sub(/,?\s*\d+(\[[^\]]*)?$/, '') # removes partial branch symbols (3[then, 3[t, 3, etc.)
206
+ end
207
+ str = truncated.gsub(/,(\s+)?$/, '') + ' ...'
192
208
  end
193
209
  str
194
210
  end
@@ -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.9.4 ruby lib
5
+ # stub: simplecov-console 0.9.5 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "simplecov-console".freeze
9
- s.version = "0.9.4"
9
+ s.version = "0.9.5"
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 = "2025-07-23"
14
+ s.date = "2026-02-02"
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 = [
@@ -1,6 +1,6 @@
1
1
  require 'helper'
2
2
 
3
- class TestSimplecovConsole < MiniTest::Test
3
+ class TestSimplecovConsole < Minitest::Test
4
4
 
5
5
  # mock for SimpleCov::SourceFile::Line
6
6
  Line = Struct.new(:line_number)
@@ -41,6 +41,9 @@ class TestSimplecovConsole < MiniTest::Test
41
41
  def teardown
42
42
  SimpleCov::Formatter::Console.output_style = 'table'
43
43
  SimpleCov::Formatter::Console.max_lines = 0
44
+ SimpleCov::Formatter::Console.missing_len = 0
45
+ SimpleCov::Formatter::Console.branch_missing_len = 0
46
+ SimpleCov::Formatter::Console.use_colors = true
44
47
  end
45
48
 
46
49
  def test_defined
@@ -119,4 +122,61 @@ class TestSimplecovConsole < MiniTest::Test
119
122
  expected = "\n file: foo.rb\ncoverage: 40.00% (2/5 lines)\n missed: 1, 4-5\nbranches: 50.00% (1/2 branches)\n missed: 2[then]\n\n"
120
123
  assert_equal expected, @console.output(files,'/',true)
121
124
  end
125
+
126
+ def test_trunc_with_line_type
127
+ SimpleCov::Formatter::Console.missing_len = 10
128
+
129
+ assert_equal "1, 2, 3, 4 ...", @console.trunc("1, 2, 3, 4, 5", type: :line)
130
+ assert_equal "short", @console.trunc("short", type: :line)
131
+ end
132
+
133
+ def test_trunc_with_branch_type
134
+ SimpleCov::Formatter::Console.branch_missing_len = 16
135
+
136
+ assert_equal "1[then], 2[else]", @console.trunc("1[then], 2[else]", type: :branch)
137
+ assert_equal "1[then], 2[else] ...", @console.trunc("1[then], 2[else], 3[then]", type: :branch)
138
+ end
139
+
140
+ def test_trunc_branch_independent_of_missing_len
141
+ SimpleCov::Formatter::Console.missing_len = 5
142
+ SimpleCov::Formatter::Console.branch_missing_len = 20
143
+
144
+ assert_equal "1[then], 2[else]", @console.trunc("1[then], 2[else]", type: :branch)
145
+ assert_equal "1, 2 ...", @console.trunc("1, 2, 3, 4", type: :line)
146
+ end
147
+
148
+ def test_block_output_with_truncated_branches
149
+ SimpleCov::Formatter::Console.use_colors = false
150
+ SimpleCov::Formatter::Console.output_style = 'block'
151
+ SimpleCov::Formatter::Console.branch_missing_len = 10
152
+ @console.include_output_style
153
+
154
+ files = [
155
+ SourceFileWithBranches.new(
156
+ 'foo.rb', 5, [2, 3], [Line.new(1)], 40.0,
157
+ {branch: CoverageStatistics.new(25.0)}, [1, 2, 3, 4],
158
+ [Branch.new(2, :then), Branch.new(3, :else), Branch.new(4, :then)]
159
+ )
160
+ ]
161
+ actual = @console.output(files, '/', true)
162
+
163
+ assert_includes actual, "2[then] ..."
164
+ end
165
+
166
+ def test_table_output_with_truncated_branches
167
+ SimpleCov::Formatter::Console.output_style = 'table'
168
+ SimpleCov::Formatter::Console.branch_missing_len = 10
169
+ @console.include_output_style
170
+
171
+ files = [
172
+ SourceFileWithBranches.new(
173
+ 'foo.rb', 5, [2, 3], [Line.new(1)], 40.0,
174
+ {branch: CoverageStatistics.new(25.0)}, [1, 2, 3, 4],
175
+ [Branch.new(2, :then), Branch.new(3, :else), Branch.new(4, :then)]
176
+ )
177
+ ]
178
+ actual = @console.output(files, '/', true)
179
+
180
+ assert_includes actual.to_s, "2[then] ..."
181
+ end
122
182
  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.9.4
4
+ version: 0.9.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chetan Sarva
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-07-23 00:00:00.000000000 Z
11
+ date: 2026-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: simplecov