simplecov-console 0.9.2 → 0.9.4

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: 9989568c37dab62aec3e405242d62a25ef30814157f5d215d7536db51ef4ea47
4
- data.tar.gz: 261234175d7b020155c10e3ed8614c0e63872dfef4af3c02b752d4408b65fcc4
3
+ metadata.gz: 3a1267b23851a2258f22f2d61dc91e3b4d83d4ccca4a4b5cd55088acdd490555
4
+ data.tar.gz: f81eb0ea573d57e201d9a310d0fcff5eba351d499af5bf42519c0f9399a18c33
5
5
  SHA512:
6
- metadata.gz: b017a907fc90934dbc77b3116f90713b6469e23ab7a391a6cd9e2b887e307d98ea16464a3c432cc8a3eac0040cdded334250298e87742b06f3e411ea36145268
7
- data.tar.gz: f82b352890c4ca0cd0577f2a8cd9d03baa8bce70e5df04299fe62dd7439c602a9cedd3e8645eb088719530a9efd9e379346b3ed79af994b978a3fa485659d1da
6
+ metadata.gz: ce0da6a41195df38f755027e5573a2a5236c8b1445f2ef41349b4748828a487a8c067115e3a188a48525b1ecc25c1c9079cf6e185c02c6cb26426cc48b59140f
7
+ data.tar.gz: 468c6aeb7d79dba8ca66c7e57341f0a02a88a7b39f6a27b47ffd71ca5bd0a623c85196d42d9459abe5f3649e4bc6921808dd93a81240147e10899e00a2969fb9
data/README.md CHANGED
@@ -53,6 +53,7 @@ code, generally in your test helper or setup file.
53
53
  ### Options
54
54
 
55
55
  ```ruby
56
+ SimpleCov::Formatter::Console.use_colors = false # true (default) or false
56
57
  SimpleCov::Formatter::Console.sort = 'path' # sort by file path
57
58
  SimpleCov::Formatter::Console.show_covered = true # show all files in coverage report
58
59
  SimpleCov::Formatter::Console.max_rows = 15 # integer
@@ -60,6 +61,8 @@ SimpleCov::Formatter::Console.max_lines = 5 # integer
60
61
  SimpleCov::Formatter::Console.missing_len = 20 # integer
61
62
  SimpleCov::Formatter::Console.output_style = 'block' # 'table' (default) or 'block'
62
63
  SimpleCov::Formatter::Console.table_options = {:style => {:width => 200}}
64
+ SimpleCov::Formatter::Console.output_to_file = false
65
+ SimpleCov::Formatter::Console.output_filename = 'results.txt'
63
66
  ```
64
67
 
65
68
  Note that all options except `table_options` can also be set via env var using
@@ -67,7 +70,13 @@ the uppercase name, e.g., `MAX_ROWS`.
67
70
 
68
71
  #### Disabling colorized output
69
72
 
70
- Color support is active by default. To disable, export `NO_COLOR=1`:
73
+ Color support is active by default. To disable:
74
+
75
+ ```ruby
76
+ SimpleCov::Formatter::Console.use_colors = false
77
+ ```
78
+
79
+ Or export `NO_COLOR=1`:
71
80
 
72
81
  ```sh
73
82
  NO_COLOR=1 rake test
@@ -130,6 +139,16 @@ increasing the table width:
130
139
  SimpleCov::Formatter::Console.table_options = {:style => {:width => 200}}
131
140
  ```
132
141
 
142
+ #### Output to File and filename
143
+
144
+ Saves the results to a file defaulted as 'results.txt' (customisable with the `output_filename` option) in the coverage folder.
145
+ Default is false to match existing functionality
146
+
147
+ ```ruby
148
+ SimpleCov::Formatter::Console.output_to_file = true
149
+ SimpleCov::Formatter::Console.output_filename = 'my_coverage.txt'
150
+ ```
151
+
133
152
  #### Block output style
134
153
 
135
154
  As an alternative to the default table output format, a simpler block format is
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.2
1
+ 0.9.4
@@ -5,7 +5,7 @@ class SimpleCov::Formatter::Console
5
5
  VERSION = IO.read(File.expand_path("../../VERSION", __FILE__)).strip
6
6
 
7
7
  ATTRIBUTES = [:table_options, :use_colors, :max_rows, :max_lines,
8
- :missing_len, :show_covered, :sort, :output_style]
8
+ :missing_len, :show_covered, :sort, :output_style, :output_to_file, :output_filename]
9
9
 
10
10
  class << self
11
11
  attr_accessor(*ATTRIBUTES)
@@ -31,6 +31,12 @@ class SimpleCov::Formatter::Console
31
31
  # configure output format ('table', 'block')
32
32
  SimpleCov::Formatter::Console.output_style = ENV.fetch('OUTPUT_STYLE', 'table')
33
33
 
34
+ # change output to a file
35
+ SimpleCov::Formatter::Console.output_to_file = ENV.fetch('SIMPLECOV_OUTPUT_TO_FILE', false)
36
+
37
+ # Related to above setting to change the filename
38
+ SimpleCov::Formatter::Console.output_filename = ENV.fetch('SIMPLECOV_OUTPUT_FILENAME', 'results.txt')
39
+
34
40
  def include_output_style
35
41
  if SimpleCov::Formatter::Console.output_style == 'block' then
36
42
  require 'simplecov-console/output/block'
@@ -61,7 +67,15 @@ class SimpleCov::Formatter::Console
61
67
  root = Dir.pwd
62
68
  end
63
69
 
64
- puts
70
+ result_file_path = ''
71
+ if SimpleCov::Formatter::Console.output_to_file
72
+ result_file_path = File.join(SimpleCov.coverage_path, SimpleCov::Formatter::Console.output_filename)
73
+ # Temporarily assign $stdout to the file
74
+ file = File.open(result_file_path, 'w')
75
+ $stdout = file
76
+ end
77
+
78
+ puts unless SimpleCov::Formatter::Console.output_to_file
65
79
  puts "COVERAGE: #{colorize(pct(result.covered_percent))} -- #{result.covered_lines}/#{result.total_lines} lines in #{result.files.size} files"
66
80
  show_branch_coverage = show_branch_coverage?(result)
67
81
  if show_branch_coverage
@@ -115,6 +129,12 @@ class SimpleCov::Formatter::Console
115
129
  puts "#{covered_files} file(s) with 100% coverage not shown"
116
130
  end
117
131
 
132
+ if SimpleCov::Formatter::Console.output_to_file
133
+ # Restore $stdout to its original state
134
+ $stdout = STDOUT
135
+ file.close
136
+ puts "Coverage report generated for #{result.command_name} to #{result_file_path}"
137
+ end
118
138
  end
119
139
 
120
140
  def branches_missed(missed_branches)
@@ -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.2 ruby lib
5
+ # stub: simplecov-console 0.9.4 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "simplecov-console".freeze
9
- s.version = "0.9.2".freeze
9
+ s.version = "0.9.4"
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 = "2024-09-17"
14
+ s.date = "2025-07-23"
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 = [
@@ -36,17 +36,29 @@ Gem::Specification.new do |s|
36
36
  ]
37
37
  s.homepage = "http://github.com/chetan/simplecov-console".freeze
38
38
  s.licenses = ["MIT".freeze]
39
- s.rubygems_version = "3.5.9".freeze
39
+ s.rubygems_version = "3.3.26".freeze
40
40
  s.summary = "Simple console output formatter".freeze
41
41
 
42
- s.specification_version = 4
42
+ if s.respond_to? :specification_version then
43
+ s.specification_version = 4
44
+ end
43
45
 
44
- s.add_runtime_dependency(%q<simplecov>.freeze, [">= 0".freeze])
45
- s.add_runtime_dependency(%q<terminal-table>.freeze, [">= 0".freeze])
46
- s.add_runtime_dependency(%q<ansi>.freeze, [">= 0".freeze])
47
- s.add_development_dependency(%q<minitest>.freeze, [">= 0".freeze])
48
- s.add_development_dependency(%q<yard>.freeze, [">= 0".freeze])
49
- s.add_development_dependency(%q<bundler>.freeze, ["~> 2.1".freeze])
50
- s.add_development_dependency(%q<juwelier>.freeze, [">= 0".freeze])
46
+ if s.respond_to? :add_runtime_dependency then
47
+ s.add_runtime_dependency(%q<simplecov>.freeze, [">= 0"])
48
+ s.add_runtime_dependency(%q<terminal-table>.freeze, [">= 0"])
49
+ s.add_runtime_dependency(%q<ansi>.freeze, [">= 0"])
50
+ s.add_development_dependency(%q<minitest>.freeze, [">= 0"])
51
+ s.add_development_dependency(%q<yard>.freeze, [">= 0"])
52
+ s.add_development_dependency(%q<bundler>.freeze, ["~> 2.1"])
53
+ s.add_development_dependency(%q<juwelier>.freeze, [">= 0"])
54
+ else
55
+ s.add_dependency(%q<simplecov>.freeze, [">= 0"])
56
+ s.add_dependency(%q<terminal-table>.freeze, [">= 0"])
57
+ s.add_dependency(%q<ansi>.freeze, [">= 0"])
58
+ s.add_dependency(%q<minitest>.freeze, [">= 0"])
59
+ s.add_dependency(%q<yard>.freeze, [">= 0"])
60
+ s.add_dependency(%q<bundler>.freeze, ["~> 2.1"])
61
+ s.add_dependency(%q<juwelier>.freeze, [">= 0"])
62
+ end
51
63
  end
52
64
 
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.2
4
+ version: 0.9.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chetan Sarva
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-09-17 00:00:00.000000000 Z
11
+ date: 2025-07-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: simplecov
@@ -149,7 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
149
149
  - !ruby/object:Gem::Version
150
150
  version: '0'
151
151
  requirements: []
152
- rubygems_version: 3.5.9
152
+ rubygems_version: 3.3.26
153
153
  signing_key:
154
154
  specification_version: 4
155
155
  summary: Simple console output formatter