simplecov_covview 0.1.0 → 0.2.1
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 +4 -4
- data/Gemfile +12 -11
- data/README.md +2 -0
- data/lib/simplecov_covview/color.rb +93 -0
- data/lib/simplecov_covview/formatter.rb +1 -1
- data/lib/simplecov_covview/line.rb +11 -5
- data/lib/simplecov_covview/resultfile.rb +4 -4
- data/lib/simplecov_covview/srcfile.rb +4 -3
- data/lib/simplecov_covview/version.rb +5 -5
- data/lib/simplecov_covview.rb +27 -18
- data/simplecov_covview.gemspec +29 -27
- metadata +31 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 28f6fa6f8b0245da23b7492dc9115148d12d576d022f7b8468e64a689cb48bda
|
4
|
+
data.tar.gz: 3227b8d839c3f2f2146d4f93a1624193e1004b5a4a1c7c004dc0e48a1bf320d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a53bcfe6d9e216dc266189968e823c92f2057cf42cf63913fed9a7f8af528baac3461c81653c00ae8c624cd4266f307af02d0e8cd056b6b060cef4df484b121b
|
7
|
+
data.tar.gz: 65662a84309ea96dd50d4e2e3e775b377fa76b9e7de957cfb67179583048add12b0e6b53347e98c7cf54d7d412eef19c8af18346df713b5788d2e6b28cecdaa1
|
data/Gemfile
CHANGED
@@ -1,11 +1,12 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
source "https://rubygems.org"
|
4
|
-
|
5
|
-
# Specify your gem's dependencies in simplecov_covview.gemspec
|
6
|
-
gemspec
|
7
|
-
|
8
|
-
gem "rake", "~> 13.0"
|
9
|
-
gem "simplecov"
|
10
|
-
|
11
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
# Specify your gem's dependencies in simplecov_covview.gemspec
|
6
|
+
gemspec
|
7
|
+
|
8
|
+
gem "rake", "~> 13.0"
|
9
|
+
gem "simplecov"
|
10
|
+
gem 'rainbow'
|
11
|
+
|
12
|
+
gem "test-unit", "~> 3.0"
|
data/README.md
CHANGED
@@ -0,0 +1,93 @@
|
|
1
|
+
module SimplecovCovview
|
2
|
+
require 'rainbow/refinement'
|
3
|
+
|
4
|
+
class CovView
|
5
|
+
class Srcfile
|
6
|
+
class Color
|
7
|
+
using Rainbow
|
8
|
+
|
9
|
+
# 8 colors colorscheme
|
10
|
+
COLOR_8 = {
|
11
|
+
covered: {
|
12
|
+
color: :white,
|
13
|
+
background: :green
|
14
|
+
},
|
15
|
+
missed: {
|
16
|
+
color: :white,
|
17
|
+
background: :red
|
18
|
+
},
|
19
|
+
}
|
20
|
+
|
21
|
+
# 256 colors colorscheme
|
22
|
+
COLOR_256 = {
|
23
|
+
covered: {
|
24
|
+
color: :black,
|
25
|
+
background: :lightgreen
|
26
|
+
},
|
27
|
+
missed: {
|
28
|
+
color: :black,
|
29
|
+
background: :lightpink
|
30
|
+
},
|
31
|
+
}
|
32
|
+
|
33
|
+
# Colorize the source file detail view
|
34
|
+
#
|
35
|
+
# @param [Array] status @src_files_line
|
36
|
+
# @param [Array] contents @src_files_line
|
37
|
+
def initialize(status, contents)
|
38
|
+
@status = status
|
39
|
+
@contents = contents
|
40
|
+
@colorscheme = {}
|
41
|
+
set_colorscheme
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
def use_8colors?
|
46
|
+
SimpleCov::Formatter::CovView.use_8color ||= false
|
47
|
+
end
|
48
|
+
|
49
|
+
def use_256colors?
|
50
|
+
SimpleCov::Formatter::CovView.use_256color ||= false
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
def set_colorscheme
|
55
|
+
@colorscheme = COLOR_8 if use_8colors?
|
56
|
+
@colorscheme = COLOR_256 if use_256colors?
|
57
|
+
end
|
58
|
+
|
59
|
+
def covered_color
|
60
|
+
@colorscheme[:covered][:color]
|
61
|
+
end
|
62
|
+
|
63
|
+
def covered_background
|
64
|
+
@colorscheme[:covered][:background]
|
65
|
+
end
|
66
|
+
|
67
|
+
def missed_color
|
68
|
+
@colorscheme[:missed][:color]
|
69
|
+
end
|
70
|
+
|
71
|
+
def missed_background
|
72
|
+
@colorscheme[:missed][:background]
|
73
|
+
end
|
74
|
+
|
75
|
+
def colorize
|
76
|
+
return @contents unless (use_8colors? || use_256colors?)
|
77
|
+
|
78
|
+
case @status
|
79
|
+
when "covered"
|
80
|
+
out_str = Rainbow(@contents).color(covered_color).bg(covered_background)
|
81
|
+
when "missed"
|
82
|
+
out_str = Rainbow(@contents).color(missed_color).bg(missed_background)
|
83
|
+
else
|
84
|
+
out_str = @contents
|
85
|
+
end
|
86
|
+
|
87
|
+
out_str
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
@@ -1,11 +1,11 @@
|
|
1
|
-
# Create text for each line from @src_files_list.
|
2
|
-
#
|
3
|
-
# @param [Hash] line @src_files_list
|
4
|
-
# @param [Hash] src_file @src_files_list
|
5
1
|
module SimplecovCovview
|
6
2
|
class CovView
|
7
3
|
class Srcfile
|
8
4
|
class Line
|
5
|
+
# Create text for each line from @src_files_list.
|
6
|
+
#
|
7
|
+
# @param [Hash] line @src_files_list
|
8
|
+
# @param [Hash] src_file @src_files_list
|
9
9
|
def initialize(line, src_file)
|
10
10
|
@line = line
|
11
11
|
@src_file = src_file
|
@@ -40,9 +40,15 @@ module SimplecovCovview
|
|
40
40
|
sprintf("%#{line_width}s: ", line_number),
|
41
41
|
sprintf("[%7s] ", status),
|
42
42
|
sprintf("[%#{cov_width}s ] ", cov_count),
|
43
|
-
source_code,
|
43
|
+
source_code.chomp("\r\n"),
|
44
44
|
].join
|
45
45
|
end
|
46
|
+
|
47
|
+
def colorize_contents
|
48
|
+
row = SimplecovCovview::CovView::Srcfile::Color.new(status, contents)
|
49
|
+
row.colorize
|
50
|
+
end
|
51
|
+
|
46
52
|
end
|
47
53
|
end
|
48
54
|
end
|
@@ -1,10 +1,10 @@
|
|
1
|
-
|
2
|
-
#
|
3
|
-
# @param [Hash] file SimpleCov::SourceFile
|
1
|
+
|
4
2
|
module SimplecovCovview
|
5
3
|
class CovView
|
6
4
|
class Resultfile
|
7
|
-
|
5
|
+
# The Resultfile class stores source file's information.
|
6
|
+
#
|
7
|
+
# @param [Hash] file SimpleCov::SourceFile
|
8
8
|
def initialize(file)
|
9
9
|
@file = file
|
10
10
|
end
|
@@ -1,9 +1,10 @@
|
|
1
|
-
|
2
|
-
#
|
3
|
-
# @param [Hash] src_file @src_files_list
|
1
|
+
|
4
2
|
module SimplecovCovview
|
5
3
|
class CovView
|
6
4
|
class Srcfile
|
5
|
+
# Create coverage header from @src_files_list.
|
6
|
+
#
|
7
|
+
# @param [Hash] src_file @src_files_list
|
7
8
|
def initialize(src_file)
|
8
9
|
@src_file = src_file
|
9
10
|
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module SimplecovCovview
|
4
|
-
VERSION = "0.1
|
5
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SimplecovCovview
|
4
|
+
VERSION = "0.2.1"
|
5
|
+
end
|
data/lib/simplecov_covview.rb
CHANGED
@@ -1,18 +1,27 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative "simplecov_covview/version"
|
4
|
-
require_relative "simplecov_covview/formatter"
|
5
|
-
require_relative "simplecov_covview/resultfile.rb"
|
6
|
-
require_relative "simplecov_covview/srcfile.rb"
|
7
|
-
require_relative "simplecov_covview/line.rb"
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "simplecov_covview/version"
|
4
|
+
require_relative "simplecov_covview/formatter"
|
5
|
+
require_relative "simplecov_covview/resultfile.rb"
|
6
|
+
require_relative "simplecov_covview/srcfile.rb"
|
7
|
+
require_relative "simplecov_covview/line.rb"
|
8
|
+
require_relative "simplecov_covview/color.rb"
|
9
|
+
|
10
|
+
module SimpleCov
|
11
|
+
module Formatter
|
12
|
+
class CovView
|
13
|
+
|
14
|
+
class << self
|
15
|
+
attr_accessor :use_8color
|
16
|
+
attr_accessor :use_256color
|
17
|
+
end
|
18
|
+
|
19
|
+
SimpleCov::Formatter::CovView.use_8color = true
|
20
|
+
|
21
|
+
def format(result)
|
22
|
+
covview = SimplecovCovview::CovView.new(result)
|
23
|
+
covview.formatter.render
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/simplecov_covview.gemspec
CHANGED
@@ -1,27 +1,29 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative "lib/simplecov_covview/version"
|
4
|
-
|
5
|
-
Gem::Specification.new do |spec|
|
6
|
-
spec.name = "simplecov_covview"
|
7
|
-
spec.version = SimplecovCovview::VERSION
|
8
|
-
spec.authors = ["icm7216"]
|
9
|
-
spec.email = ["icm7216d@gmail.com"]
|
10
|
-
|
11
|
-
spec.summary = "Coverage viewer for simplecov."
|
12
|
-
spec.description = "Coverage console output formatter for SimpleCov."
|
13
|
-
spec.homepage = "https://github.com/icm7216/simplecov_covview"
|
14
|
-
spec.license = "MIT"
|
15
|
-
spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
|
16
|
-
|
17
|
-
# Specify which files should be added to the gem when it is released.
|
18
|
-
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
19
|
-
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
20
|
-
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
|
21
|
-
end
|
22
|
-
spec.bindir = "exe"
|
23
|
-
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
24
|
-
spec.require_paths = ["lib"]
|
25
|
-
|
26
|
-
spec.add_development_dependency "test-unit"
|
27
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/simplecov_covview/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "simplecov_covview"
|
7
|
+
spec.version = SimplecovCovview::VERSION
|
8
|
+
spec.authors = ["icm7216"]
|
9
|
+
spec.email = ["icm7216d@gmail.com"]
|
10
|
+
|
11
|
+
spec.summary = "Coverage viewer for simplecov."
|
12
|
+
spec.description = "Coverage console output formatter for SimpleCov."
|
13
|
+
spec.homepage = "https://github.com/icm7216/simplecov_covview"
|
14
|
+
spec.license = "MIT"
|
15
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
|
16
|
+
|
17
|
+
# Specify which files should be added to the gem when it is released.
|
18
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
19
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
20
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
|
21
|
+
end
|
22
|
+
spec.bindir = "exe"
|
23
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
24
|
+
spec.require_paths = ["lib"]
|
25
|
+
|
26
|
+
spec.add_development_dependency "test-unit"
|
27
|
+
spec.add_development_dependency "simplecov"
|
28
|
+
spec.add_development_dependency "rainbow"
|
29
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simplecov_covview
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- icm7216
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-08-
|
11
|
+
date: 2021-08-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: test-unit
|
@@ -24,6 +24,34 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: simplecov
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rainbow
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
27
55
|
description: Coverage console output formatter for SimpleCov.
|
28
56
|
email:
|
29
57
|
- icm7216d@gmail.com
|
@@ -39,6 +67,7 @@ files:
|
|
39
67
|
- bin/console
|
40
68
|
- bin/setup
|
41
69
|
- lib/simplecov_covview.rb
|
70
|
+
- lib/simplecov_covview/color.rb
|
42
71
|
- lib/simplecov_covview/formatter.rb
|
43
72
|
- lib/simplecov_covview/line.rb
|
44
73
|
- lib/simplecov_covview/resultfile.rb
|