single_cov 0.8.4 → 1.0.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
- SHA1:
3
- metadata.gz: 37412e211f8574c2160896a6703e98b40c7d4940
4
- data.tar.gz: f98008886892599241ab7c2e64444e38ac642138
2
+ SHA256:
3
+ metadata.gz: 93bc47f24f33d85ed88bc31457af86b4279569239a10ca58a7c68559f50c03bb
4
+ data.tar.gz: 4ff3f11d836b2204eb9273418529fec04d4f6442cfc066cd7ea42f22fc892615
5
5
  SHA512:
6
- metadata.gz: 37578a95335ffbc37f69c63f21a8cc7b7a32eec86245bcf6a5170ce86216d0f812cfcb478a047e6c9652a66ce9aa8066750768f865b76010c8e63afb212ad49b
7
- data.tar.gz: e6a801e4480356c859ab14eb7760dd2967286e90f38165c5cfd8f391fa8a0e04830989daa80ebfb9ad143d36afa5184e066530719e3a30628d83876df945db3c
6
+ metadata.gz: cd2d503a59f3ee64cd5dca10901f99e53d4b57a0e2700b4ada42187c6924f1a1f56473b297fc7e86648ba858901f89d6fd4fe899dae0726faf0429ca57baf32d
7
+ data.tar.gz: 74dce791fd81148ecd84d2b247a0daa6db34a40870f3378f58dce4ab8d03f1fc7f1bd6a838a8610760cfc2b426cb7515a348d24bb8cddef94937cdd23d7243a6
@@ -1,3 +1,3 @@
1
1
  module SingleCov
2
- VERSION = "0.8.4"
2
+ VERSION = "1.0.0"
3
3
  end
data/lib/single_cov.rb CHANGED
@@ -2,6 +2,7 @@ module SingleCov
2
2
  COVERAGES = []
3
3
  MAX_OUTPUT = 40
4
4
  APP_FOLDERS = ["models", "serializers", "helpers", "controllers", "mailers", "views", "jobs"]
5
+ BRANCH_COVERAGE_SUPPORTED = (RUBY_VERSION >= "2.5.0")
5
6
 
6
7
  class << self
7
8
  # optionally rewrite the file we guessed with a lambda
@@ -66,18 +67,16 @@ module SingleCov
66
67
  end
67
68
  end
68
69
 
69
- def setup(framework, root: nil, branches: false)
70
+ def setup(framework, root: nil, branches: BRANCH_COVERAGE_SUPPORTED)
70
71
  if defined?(SimpleCov)
71
72
  raise "Load SimpleCov after SingleCov"
72
73
  end
73
- if branches && RUBY_VERSION < "2.5.0"
74
- warn "Branch coverage needs ruby 2.5.0"
75
- @branches = false
76
- else
77
- @branches = branches
74
+ if branches && !BRANCH_COVERAGE_SUPPORTED
75
+ raise "Branch coverage needs ruby >= 2.5.0"
78
76
  end
79
77
 
80
- @root = root if root
78
+ @branches = branches
79
+ @root = root
81
80
 
82
81
  case framework
83
82
  when :minitest
@@ -104,11 +103,17 @@ module SingleCov
104
103
  private
105
104
 
106
105
  def uncovered_branches(file, coverage, uncovered_lines)
107
- found = coverage.each_value.flat_map do |branch_part|
108
- branch_part.
109
- select { |k, v| v.zero? && !uncovered_lines.include?(k[2]) }.
110
- map { |k, _| "#{file}:#{k[2]}:#{k[3]+1}-#{k[4]}:#{k[5]+1}" }
106
+ # {[branch_id] => {[branch_part] => coverage}} --> {branch_part -> sum-of-coverage}
107
+ sum = Hash.new(0)
108
+ coverage.each_value do |branch|
109
+ branch.each do |k, v|
110
+ sum[k.slice(2, 4)] += v
111
+ end
111
112
  end
113
+
114
+ # show missing coverage
115
+ found = sum.select { |k, v| v.zero? && !uncovered_lines.include?(k[0]) }.
116
+ map { |k, _| "#{file}:#{k[0]}:#{k[1]+1}-#{k[2]}:#{k[3]+1}" }
112
117
  found.sort!
113
118
  found.uniq!
114
119
  found
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: single_cov
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.4
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Grosser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-19 00:00:00.000000000 Z
11
+ date: 2018-03-03 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: michael@grosser.it
@@ -39,7 +39,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
39
39
  version: '0'
40
40
  requirements: []
41
41
  rubyforge_project:
42
- rubygems_version: 2.6.14
42
+ rubygems_version: 2.7.3
43
43
  signing_key:
44
44
  specification_version: 4
45
45
  summary: Actionable code coverage.