simplecov-console 0.5.0 → 0.6.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: 290f9f7dda635d7301e3c4f2acd9bb81a17fda27aee5a812983ba19bfea11ebe
4
- data.tar.gz: 2e317c4c10cf7dff407e2544c2916136c7d436f35a89fc10a509649a8706d32c
3
+ metadata.gz: bf41260176ece548059c1fff6db115552f4ff1a6655ab63575e488dfc2318739
4
+ data.tar.gz: 404ddb9d0b0a6f023046fdf7f52ab4accd496cc759f37c696d22c73df9a5d194
5
5
  SHA512:
6
- metadata.gz: 2de0c0d1e3b265df0d214368841200362feee6817497562d0ad04246b2c2ab81346e714242bd767bf8ffbe7fdca8d321061559a5a05a47a09fe2c79f14df91bd
7
- data.tar.gz: 0d6bd990215178e64db73696dfa06454ba46d0f72771e380114d9c881e7945fc0e7c33dcc010b8c5b1b598eb4f4a2ad3cb39aff921c298446bc375306a66102f
6
+ metadata.gz: 2e66ac79cbdf147451f2d6cb27666cd9b9a9cafc4c440adf6cc5975af38423f850260ffd3c40410a59e10ebc33b2e23438255c196ae1412a84647d10fb5350a0
7
+ data.tar.gz: 0c9e6517b4a51a435c02f2a3e96def76c7d9bf0724f725a679555a67f90b2fce7c788d0ebb464217458c48e91559e8a92837c164b91139769b6f55f93a7d3ae5
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,17 +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
+
47
84
  ### Table options
48
85
 
49
- In some cases, you may need to pass some options to Hirb's Table.render. For example, if the filenames are
86
+ In some cases, you may need to pass some options to `TerminalTable.new`. For example, if the filenames are
50
87
  truncated so much that you can't read them. In that case, you can add a line like this when setting the formatter:
51
88
 
52
89
  ```ruby
53
- SimpleCov::Formatter::Console.table_options = {max_width: 200}
90
+ SimpleCov::Formatter::Console.table_options = {:style => {:width => 200}}
54
91
  SimpleCov.formatter = SimpleCov::Formatter::Console
55
92
  ```
56
93
 
57
- ### Contributing
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
104
+
105
+ ## Contributing
58
106
 
59
107
  * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
60
108
  * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
@@ -66,5 +114,5 @@ SimpleCov.formatter = SimpleCov::Formatter::Console
66
114
 
67
115
  ### Copyright
68
116
 
69
- Copyright (c) 2014 Chetan Sarva. See LICENSE.txt for
117
+ Copyright (c) 2019 Chetan Sarva. See LICENSE.txt for
70
118
  further details.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.0
1
+ 0.6.0
@@ -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]
8
+ ATTRIBUTES = [:table_options, :use_colors, :max_rows, :show_covered, :sort]
9
9
  class << self
10
10
  attr_accessor(*ATTRIBUTES)
11
11
  end
@@ -14,6 +14,15 @@ class SimpleCov::Formatter::Console
14
14
  SimpleCov::Formatter::Console.use_colors =
15
15
  (ENV['NO_COLOR'].nil? or ENV['NO_COLOR'].empty?) ? true : false
16
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')
25
+
17
26
  def format(result)
18
27
 
19
28
  root = nil
@@ -35,20 +44,26 @@ class SimpleCov::Formatter::Console
35
44
  return
36
45
  end
37
46
 
38
- 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
39
52
 
40
53
  covered_files = 0
41
- files.select!{ |file|
42
- if file.covered_percent == 100 then
43
- covered_files += 1
44
- false
45
- else
46
- true
47
- end
48
- }
49
54
 
50
- if files.nil? or files.empty? then
51
- 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
52
67
  end
53
68
 
54
69
  table = files.map do |f|
@@ -61,9 +76,11 @@ class SimpleCov::Formatter::Console
61
76
  ]
62
77
  end
63
78
 
64
- if table.size > 15 then
65
- puts "showing bottom (worst) 15 of #{table.size} files"
66
- 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)
67
84
  end
68
85
 
69
86
  table_options = SimpleCov::Formatter::Console.table_options || {}
@@ -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.0 ruby lib
5
+ # stub: simplecov-console 0.6.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "simplecov-console".freeze
9
- s.version = "0.5.0"
9
+ s.version = "0.6.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 = "2019-05-24"
14
+ s.date = "2019-11-08"
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 = [
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.5.0
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: 2019-05-24 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