checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
---
2
- SHA1:
3
- metadata.gz: c94c34b7c48536875f37cafda5470bd58a33ea50
4
- data.tar.gz: 14d9c26c608fb6712790caaee211f14a9ec429e3
2
+ SHA256:
3
+ metadata.gz: bf41260176ece548059c1fff6db115552f4ff1a6655ab63575e488dfc2318739
4
+ data.tar.gz: 404ddb9d0b0a6f023046fdf7f52ab4accd496cc759f37c696d22c73df9a5d194
5
5
SHA512:
6
- metadata.gz: 7b3c3e3f0a44ff6113909f092d4f2120a2713d58de4e467f22fd977fa8e3c022c878ac8ca2c89cf02a62c665fea4c3bbaad9e238b42ce2e22869f268fa5a1977
7
- data.tar.gz: af0311bf9c48b080d6bee9ab3470abba824f807da8ff44a26d024171632b3b41e662da920f366bd9a936a057a2b67a893e6ed128fdf0d42897569e47915dc501
6
+ metadata.gz: 2e66ac79cbdf147451f2d6cb27666cd9b9a9cafc4c440adf6cc5975af38423f850260ffd3c40410a59e10ebc33b2e23438255c196ae1412a84647d10fb5350a0
7
+ data.tar.gz: 0c9e6517b4a51a435c02f2a3e96def76c7d9bf0724f725a679555a67f90b2fce7c788d0ebb464217458c48e91559e8a92837c164b91139769b6f55f93a7d3ae5
data/Gemfile CHANGED
@@ -1,7 +1,7 @@
1
1
source "http://rubygems.org"
2
2
3
3
gem "simplecov"
4
- gem "hirb"
4
+ gem "terminal-table"
5
5
gem "ansi"
6
6
7
7
group :development do
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
3
3
A simple console output formatter for SimpleCov
4
4
5
- ### Usage
5
+ ## Usage
6
6
7
7
```bash
8
8
$ gem install simplecov-console
@@ -11,14 +11,15 @@ $ gem install simplecov-console
11
11
```ruby
12
12
SimpleCov.formatter = SimpleCov::Formatter::Console
13
13
# or
14
- SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
14
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
15
15
SimpleCov::Formatter::HTMLFormatter,
16
16
SimpleCov::Formatter::Console,
17
- ]
17
+ ])
18
18
```
19
19
20
20
Example output:
21
- ```
21
+
22
+ ```text
22
23
COVERAGE: 82.34% -- 2345/2848 lines in 111 files
23
24
24
25
showing bottom (worst) 15 of 69 files
@@ -44,8 +45,64 @@ showing bottom (worst) 15 of 69 files
44
45
42 file(s) with 100% coverage not shown
45
46
```
46
47
48
+ ## Configuration
49
+
50
+ ### Disabling colorized output
51
+
52
+ Simply export `NO_COLOR=1` and colors will be disabled.
53
+
54
+ ```sh
55
+ NO_COLOR=1 rake test
56
+ ```
57
+
58
+ ### Sorting the output
59
+
60
+ By default the coverage report is sorted by coverage % in descending order. To sort alphabetically by path, set the `SORT` environment variable to "path", or add the following to your test helper:
61
+
62
+ ```ruby
63
+ SimpleCov::Formatter::Console.sort = 'path' # sort by file path
64
+ ```
65
+
66
+ ### Showing covered files
67
+
68
+ By default, fully covered files are excluded from the report. To show them, set the `SHOW_COVERED` environment variable to `true` or add the following to your test helper:
69
+
70
+ ```ruby
71
+ SimpleCov::Formatter::Console.show_covered = true # show all files in coverage report
72
+ ```
73
+
74
+ ### Maximum rows displayed
75
+
76
+ By default, a maximum of 15 files with the worst coverage are displayed in the report. You can override this limit by setting the `MAX_ROWS` environment variable, or adding the following to your test helper:
77
+
78
+ ```ruby
79
+ SimpleCov::Formatter::Console.max_rows = # some number
80
+ ```
81
+
82
+ Setting a value of `-1` or `nil` will show all of the files.
83
+
84
+ ### Table options
85
+
86
+ In some cases, you may need to pass some options to `TerminalTable.new`. For example, if the filenames are
87
+ truncated so much that you can't read them. In that case, you can add a line like this when setting the formatter:
88
+
89
+ ```ruby
90
+ SimpleCov::Formatter::Console.table_options = {:style => {:width => 200}}
91
+ SimpleCov.formatter = SimpleCov::Formatter::Console
92
+ ```
93
+
94
+ ## History
95
+
96
+ ### 0.6 (2019.11.08)
97
+
98
+ - Added new config options: `sort`, `show_covered`, and `max_rows`
99
+
100
+ ### 0.5 (2019.05.24)
101
+
102
+ - Replaced `hirb` gem with `terminal-table` due to multiple warnings thrown ([#11](https://github.com/chetan/simplecov-console/issues/11))
103
+ - Support [disabling colorized](https://no-color.org/) output via `NO_COLOR` env var
47
104
48
- ### Contributing
105
+ ## Contributing
49
106
50
107
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
51
108
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
@@ -57,5 +114,5 @@ showing bottom (worst) 15 of 69 files
57
114
58
115
### Copyright
59
116
60
- Copyright (c) 2014 Chetan Sarva. See LICENSE.txt for
117
+ Copyright (c) 2019 Chetan Sarva. See LICENSE.txt for
61
118
further details.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.1
1
+ 0.6.0
data/lib/simplecov-console.rb CHANGED
@@ -1,9 +1,27 @@
1
- require 'hirb'
1
+ require 'terminal-table'
2
2
require 'ansi/code'
3
3
4
4
class SimpleCov::Formatter::Console
5
5
6
- VERSION = File.new(File.join(File.expand_path(File.dirname(__FILE__)), "../VERSION")).read.strip
6
+ VERSION = IO.read(File.expand_path("../../VERSION", __FILE__)).strip
7
+
8
+ ATTRIBUTES = [:table_options, :use_colors, :max_rows, :show_covered, :sort]
9
+ class << self
10
+ attr_accessor(*ATTRIBUTES)
11
+ end
12
+
13
+ # enable colors unless NO_COLOR=1
14
+ SimpleCov::Formatter::Console.use_colors =
15
+ (ENV['NO_COLOR'].nil? or ENV['NO_COLOR'].empty?) ? true : false
16
+
17
+ # configure max rows from MAX_ROWS env var
18
+ SimpleCov::Formatter::Console.max_rows = ENV.fetch('MAX_ROWS', 15).to_i
19
+
20
+ # configure show_covered from SHOW_COVERED env var
21
+ SimpleCov::Formatter::Console.show_covered = ENV.fetch('SHOW_COVERED', 'false') == 'true'
22
+
23
+ # configure sort from SORT env var
24
+ SimpleCov::Formatter::Console.sort = ENV.fetch('SORT', 'coverage')
7
25
8
26
def format(result)
9
27
@@ -26,38 +44,54 @@ class SimpleCov::Formatter::Console
26
44
return
27
45
end
28
46
29
- files = result.files.sort{ |a,b| a.covered_percent <=> b.covered_percent }
47
+ if SimpleCov::Formatter::Console.sort == 'coverage'
48
+ files = result.files.sort{ |a,b| a.covered_percent <=> b.covered_percent }
49
+ else
50
+ files = result.files
51
+ end
30
52
31
53
covered_files = 0
32
- files.select!{ |file|
33
- if file.covered_percent == 100 then
34
- covered_files += 1
35
- false
36
- else
37
- true
38
- end
39
- }
40
54
41
- if files.nil? or files.empty? then
42
- return
55
+ unless SimpleCov::Formatter::Console.show_covered
56
+ files.select!{ |file|
57
+ if file.covered_percent == 100 then
58
+ covered_files += 1
59
+ false
60
+ else
61
+ true
62
+ end
63
+ }
64
+ if files.nil? or files.empty? then
65
+ return
66
+ end
43
67
end
44
68
45
69
table = files.map do |f|
46
- { :coverage => pct(f),
47
- :lines => f.lines_of_code,
48
- :file => f.filename.gsub(root + "/", ''),
49
- :missed => f.missed_lines.count,
50
- :missing => missed(f.missed_lines).join(", ") }
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
+ ]
51
77
end
52
78
53
- if table.size > 15 then
54
- puts "showing bottom (worst) 15 of #{table.size} files"
55
- table = table.slice(0, 15)
79
+ max_rows = SimpleCov::Formatter::Console.max_rows
80
+
81
+ if ![-1, nil].include?(max_rows) && table.size > max_rows then
82
+ puts "showing bottom (worst) #{max_rows} of #{table.size} files"
83
+ table = table.slice(0, max_rows)
56
84
end
57
85
58
- s = Hirb::Helpers::Table.render(table).split(/\n/)
59
- s.pop
60
- puts s.join("\n").gsub(/\d+\.\d+%/) { |m| colorize(m) }
86
+ table_options = SimpleCov::Formatter::Console.table_options || {}
87
+ if !table_options.kind_of?(Hash) then
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
61
95
62
96
if covered_files > 0 then
63
97
puts "#{covered_files} file(s) with 100% coverage not shown"
@@ -82,11 +116,11 @@ class SimpleCov::Formatter::Console
82
116
end
83
117
84
118
group_str = []
85
- groups.map do |base, v|
86
- if v > 0
87
- group_str << "#{base}-#{base + v}"
119
+ groups.map do |starting_line, length|
120
+ if length > 0
121
+ group_str << "#{starting_line}-#{starting_line + length}"
88
122
else
89
- group_str << "#{base}"
123
+ group_str << "#{starting_line}"
90
124
end
91
125
end
92
126
@@ -97,7 +131,13 @@ class SimpleCov::Formatter::Console
97
131
sprintf("%6.2f%%", obj.covered_percent)
98
132
end
99
133
134
+ def use_colors?
135
+ SimpleCov::Formatter::Console.use_colors
136
+ end
137
+
100
138
def colorize(s)
139
+ return s if !use_colors?
140
+
101
141
s =~ /([\d.]+)/
102
142
n = $1.to_f
103
143
if n >= 90 then
data/simplecov-console.gemspec CHANGED
@@ -2,18 +2,18 @@
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.3.1 ruby lib
5
+ # stub: simplecov-console 0.6.0 ruby lib
6
6
7
7
Gem::Specification.new do |s|
8
- s.name = "simplecov-console"
9
- s.version = "0.3.1"
8
+ s.name = "simplecov-console".freeze
9
+ s.version = "0.6.0"
10
10
11
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
- s.require_paths = ["lib"]
13
- s.authors = ["Chetan Sarva"]
14
- s.date = "2016-08-25"
15
- s.description = "Simple console output formatter for SimpleCov"
16
- s.email = "chetan@pixelcop.net"
11
+ s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib".freeze]
13
+ s.authors = ["Chetan Sarva".freeze]
14
+ s.date = "2019-11-08"
15
+ s.description = "Simple console output formatter for SimpleCov".freeze
16
+ s.email = "chetan@pixelcop.net".freeze
17
17
s.extra_rdoc_files = [
18
18
"LICENSE.txt",
19
19
"README.md"
@@ -30,39 +30,39 @@ Gem::Specification.new do |s|
30
30
"test/helper.rb",
31
31
"test/test_simplecov-console.rb"
32
32
]
33
- s.homepage = "http://github.com/chetan/simplecov-console"
34
- s.licenses = ["MIT"]
35
- s.rubygems_version = "2.5.1"
36
- s.summary = "Simple console output formatter"
33
+ s.homepage = "http://github.com/chetan/simplecov-console".freeze
34
+ s.licenses = ["MIT".freeze]
35
+ s.rubygems_version = "3.0.2".freeze
36
+ s.summary = "Simple console output formatter".freeze
37
37
38
38
if s.respond_to? :specification_version then
39
39
s.specification_version = 4
40
40
41
41
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
42
- s.add_runtime_dependency(%q<simplecov>, [">= 0"])
43
- s.add_runtime_dependency(%q<hirb>, [">= 0"])
44
- s.add_runtime_dependency(%q<ansi>, [">= 0"])
45
- s.add_development_dependency(%q<minitest>, [">= 0"])
46
- s.add_development_dependency(%q<yard>, [">= 0"])
47
- s.add_development_dependency(%q<bundler>, ["~> 1.2"])
48
- s.add_development_dependency(%q<juwelier>, [">= 0"])
42
+ s.add_runtime_dependency(%q<simplecov>.freeze, [">= 0"])
43
+ s.add_runtime_dependency(%q<terminal-table>.freeze, [">= 0"])
44
+ s.add_runtime_dependency(%q<ansi>.freeze, [">= 0"])
45
+ s.add_development_dependency(%q<minitest>.freeze, [">= 0"])
46
+ s.add_development_dependency(%q<yard>.freeze, [">= 0"])
47
+ s.add_development_dependency(%q<bundler>.freeze, ["~> 1.2"])
48
+ s.add_development_dependency(%q<juwelier>.freeze, [">= 0"])
49
49
else
50
- s.add_dependency(%q<simplecov>, [">= 0"])
51
- s.add_dependency(%q<hirb>, [">= 0"])
52
- s.add_dependency(%q<ansi>, [">= 0"])
53
- s.add_dependency(%q<minitest>, [">= 0"])
54
- s.add_dependency(%q<yard>, [">= 0"])
55
- s.add_dependency(%q<bundler>, ["~> 1.2"])
56
- s.add_dependency(%q<juwelier>, [">= 0"])
50
+ s.add_dependency(%q<simplecov>.freeze, [">= 0"])
51
+ s.add_dependency(%q<terminal-table>.freeze, [">= 0"])
52
+ s.add_dependency(%q<ansi>.freeze, [">= 0"])
53
+ s.add_dependency(%q<minitest>.freeze, [">= 0"])
54
+ s.add_dependency(%q<yard>.freeze, [">= 0"])
55
+ s.add_dependency(%q<bundler>.freeze, ["~> 1.2"])
56
+ s.add_dependency(%q<juwelier>.freeze, [">= 0"])
57
57
end
58
58
else
59
- s.add_dependency(%q<simplecov>, [">= 0"])
60
- s.add_dependency(%q<hirb>, [">= 0"])
61
- s.add_dependency(%q<ansi>, [">= 0"])
62
- s.add_dependency(%q<minitest>, [">= 0"])
63
- s.add_dependency(%q<yard>, [">= 0"])
64
- s.add_dependency(%q<bundler>, ["~> 1.2"])
65
- s.add_dependency(%q<juwelier>, [">= 0"])
59
+ s.add_dependency(%q<simplecov>.freeze, [">= 0"])
60
+ s.add_dependency(%q<terminal-table>.freeze, [">= 0"])
61
+ s.add_dependency(%q<ansi>.freeze, [">= 0"])
62
+ s.add_dependency(%q<minitest>.freeze, [">= 0"])
63
+ s.add_dependency(%q<yard>.freeze, [">= 0"])
64
+ s.add_dependency(%q<bundler>.freeze, ["~> 1.2"])
65
+ s.add_dependency(%q<juwelier>.freeze, [">= 0"])
66
66
end
67
67
end
68
68
data/test/helper.rb CHANGED
@@ -1,25 +1,15 @@
1
- require 'rubygems'
2
- require 'bundler'
3
- begin
4
- Bundler.setup(:default, :development)
5
- rescue Bundler::BundlerError => e
6
- $stderr.puts e.message
7
- $stderr.puts "Run `bundle install` to install missing gems"
8
- exit e.status_code
9
- end
10
- require "simplecov"
11
- require "minitest/autorun"
12
1
13
- $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.push(File.expand_path("../../lib", __FILE__))
14
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
15
- require 'simplecov-console'
16
3
17
- class MiniTest::Test
18
- end
4
+ require "bundler/setup"
5
+ require "simplecov"
6
+ require "simplecov-console"
19
7
20
- SimpleCov.formatter = SimpleCov::Formatter::Console
21
8
SimpleCov.start do
22
- add_filter "/test/"
9
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
10
+ SimpleCov::Formatter::HTMLFormatter,
11
+ SimpleCov::Formatter::Console
12
+ ])
23
13
end
24
14
25
- MiniTest.autorun
15
+ require "minitest/autorun"
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.3.1
4
+ version: 0.6.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: 2016-08-25 00:00:00.000000000 Z
11
+ date: 2019-11-08 00:00:00.000000000 Z
12
12
dependencies:
13
13
- !ruby/object:Gem::Dependency
14
14
name: simplecov
@@ -25,7 +25,7 @@ dependencies:
25
25
- !ruby/object:Gem::Version
26
26
version: '0'
27
27
- !ruby/object:Gem::Dependency
28
- name: hirb
28
+ name: terminal-table
29
29
requirement: !ruby/object:Gem::Requirement
30
30
requirements:
31
31
- - ">="
@@ -145,8 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
145
145
- !ruby/object:Gem::Version
146
146
version: '0'
147
147
requirements: []
148
- rubyforge_project:
148
+ rubygems_version: 3.0.2
149
- rubygems_version: 2.5.1
150
149
signing_key:
151
150
specification_version: 4
152
151
summary: Simple console output formatter