usps-support 0.2.13 → 0.2.15
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/lib/usps/support/lib/simple_cov/filters_parser.rb +84 -0
- data/lib/usps/support/lib/simple_cov/uncovered_lines_formatter.rb +49 -0
- data/lib/usps/support/lib/simple_cov.rb +10 -0
- data/lib/usps/support/lib.rb +7 -0
- data/lib/usps/support/version.rb +1 -1
- data/lib/usps/support.rb +1 -0
- metadata +5 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 06f5b7ef7a2a7b3899721c10fe6a0bdf0d75f3dd04b21cb31c6acdb47908b314
|
|
4
|
+
data.tar.gz: 2557beb4fe11739cbd23aeb977fde8637f821c1e41613a1c8bf2a9ed45d56249
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a67296ed9f3f3e85bfc4e01ec8d7bdf6fb1a5b347ba32e64273f9c8ae9445a4d0d8b223600eea5c14e400e0da75030cdad94fdd6a9e7db8e52dde74de82b1932
|
|
7
|
+
data.tar.gz: 25b0c7077bc8ada1775b16bb8bcf8dfe71ac3acd29f37c7899294305ec4aa58ddd1f8b690a99b4f22ef6a177f1e6962b7c07fe015f208a05d5016164ab53d67c
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
module Usps::Support::Lib::SimpleCov
|
|
2
|
+
# Parser for converting hash filter definition into individual coverage filters
|
|
3
|
+
#
|
|
4
|
+
# Example config:
|
|
5
|
+
#
|
|
6
|
+
# {
|
|
7
|
+
# ignored_category_header: {
|
|
8
|
+
# spec: '*',
|
|
9
|
+
# app: {
|
|
10
|
+
# controllers: %w[example_1],
|
|
11
|
+
# helpers: 'example_2',
|
|
12
|
+
# models: {
|
|
13
|
+
# members: %w[example_3],
|
|
14
|
+
# _: %w[example_4]
|
|
15
|
+
# }
|
|
16
|
+
# }
|
|
17
|
+
# }
|
|
18
|
+
# }
|
|
19
|
+
#
|
|
20
|
+
# This config would generate the following coverage filters:
|
|
21
|
+
#
|
|
22
|
+
# - `/spec`
|
|
23
|
+
# - `/app/controllers/example_1.rb`
|
|
24
|
+
# - `/app/helpers/example_2.rb`
|
|
25
|
+
# - `/app/models/members/example_3.rb`
|
|
26
|
+
# - `/app/models/example_4.rb`
|
|
27
|
+
#
|
|
28
|
+
class FiltersParser
|
|
29
|
+
attr_reader :filters_config
|
|
30
|
+
|
|
31
|
+
def self.paths(...) = new(...).paths
|
|
32
|
+
|
|
33
|
+
def initialize(filters_config)
|
|
34
|
+
@filters_config = filters_config
|
|
35
|
+
@dir = []
|
|
36
|
+
@paths = []
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def paths
|
|
40
|
+
return @paths if @paths.any?
|
|
41
|
+
|
|
42
|
+
filters_config.each_value { parse_data(it) }
|
|
43
|
+
|
|
44
|
+
@paths
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
private
|
|
48
|
+
|
|
49
|
+
def parse_data(data)
|
|
50
|
+
case data
|
|
51
|
+
when '*' then filter_dir
|
|
52
|
+
when String then filter_file(data)
|
|
53
|
+
when Array then data.each { filter_file(it) }
|
|
54
|
+
when Hash then walk(data)
|
|
55
|
+
else
|
|
56
|
+
raise "Unrecognized filter format: #{data.inspect}"
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def walk(hash)
|
|
61
|
+
hash.each do |dir, sub_data|
|
|
62
|
+
with(dir) { parse_data(sub_data) }
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def with(dir)
|
|
67
|
+
@dir << dir.to_s
|
|
68
|
+
yield
|
|
69
|
+
@dir.pop
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def filter_dir
|
|
73
|
+
@paths << dir_path
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def filter_file(filename)
|
|
77
|
+
@paths << File.join(dir_path, "#{filename}.rb")
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def dir_path
|
|
81
|
+
"/#{File.join(@dir)}".sub(%r{/_}, '') if @dir.any?
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
module Usps::Support::Lib::SimpleCov
|
|
2
|
+
# Simple coverage formatter to display paths of any uncovered lines
|
|
3
|
+
#
|
|
4
|
+
# Intended to make it quicker to know what was uncovered, especially when
|
|
5
|
+
# running in GitHub Actions
|
|
6
|
+
#
|
|
7
|
+
# rubocop:disable Rails/Output
|
|
8
|
+
class UncoveredLinesFormatter
|
|
9
|
+
attr_reader :uncovered_files
|
|
10
|
+
|
|
11
|
+
def format(result)
|
|
12
|
+
@uncovered_files = result.files.reject { it.missed_lines.empty? }
|
|
13
|
+
return unless uncovered_files.any?
|
|
14
|
+
|
|
15
|
+
puts 'Uncovered lines:'
|
|
16
|
+
uncovered_files.each { report(it) }
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
private
|
|
20
|
+
|
|
21
|
+
def report(file)
|
|
22
|
+
missed = pad(file.missed_lines.size)
|
|
23
|
+
total = pad(file.lines_of_code)
|
|
24
|
+
percent = file.covered_percent.round(2).to_s.rjust(5, ' ')
|
|
25
|
+
|
|
26
|
+
puts " [#{missed} / #{total} : #{percent}%] #{file.filename}"
|
|
27
|
+
puts " Lines: #{line_number_ranges(file).join(', ')}"
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def pad(number) = number.to_s.rjust(max_line_count_length, ' ')
|
|
31
|
+
|
|
32
|
+
def max_line_count_length
|
|
33
|
+
@max_line_count_length ||= uncovered_files.map(&:lines_of_code).max.to_s.length
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def line_number_ranges(file)
|
|
37
|
+
file
|
|
38
|
+
.missed_lines
|
|
39
|
+
.map(&:line_number)
|
|
40
|
+
.chunk
|
|
41
|
+
.with_index { |number, index| number - index }
|
|
42
|
+
.map do |_diff, group|
|
|
43
|
+
first, *, last = group
|
|
44
|
+
last.nil? ? first : "#{first}-#{last}"
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
# rubocop:enable Rails/Output
|
|
49
|
+
end
|
data/lib/usps/support/version.rb
CHANGED
data/lib/usps/support.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: usps-support
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.15
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Julian Fiander
|
|
@@ -69,6 +69,10 @@ files:
|
|
|
69
69
|
- lib/usps/support/helpers/git_helper.rb
|
|
70
70
|
- lib/usps/support/helpers/react_helper.rb
|
|
71
71
|
- lib/usps/support/helpers/scss_helper.rb
|
|
72
|
+
- lib/usps/support/lib.rb
|
|
73
|
+
- lib/usps/support/lib/simple_cov.rb
|
|
74
|
+
- lib/usps/support/lib/simple_cov/filters_parser.rb
|
|
75
|
+
- lib/usps/support/lib/simple_cov/uncovered_lines_formatter.rb
|
|
72
76
|
- lib/usps/support/models.rb
|
|
73
77
|
- lib/usps/support/models/dynamo_db.rb
|
|
74
78
|
- lib/usps/support/models/git_hub.rb
|