Class: SimpleCov::Configuration::CoverageCriterion
- Inherits:
-
Object
- Object
- SimpleCov::Configuration::CoverageCriterion
- Defined in:
- lib/simplecov/configuration/coverage.rb,
sig/simplecov.rbs
Overview
Receiver for a coverage <criterion> do ... end block.
Defined Under Namespace
Classes: GroupTarget
Instance Method Summary collapse
- #exact(percent) ⇒ void
- #group(name) ⇒ GroupTarget
-
#ignore(*types) ⇒ Array[Symbol]
The flatten serves the one-liner keyword form, whose value arrives as a single argument (
ignore: %i[implicit_else]). -
#initialize(config, criterion) ⇒ CoverageCriterion
constructor
A new instance of CoverageCriterion.
- #maximum(percent) ⇒ void
- #maximum_drop(percent) ⇒ void
- #maximum_missed(count, per: nil) ⇒ void
- #maximum_missed_per_file(count, only: nil) ⇒ void
- #minimum(percent, per: nil) ⇒ void
- #minimum_per_file(percent, only: nil) ⇒ void
- #minimum_per_group(percent, only:) ⇒ void
- #primary ⇒ void
- #raise_invalid_per(per) ⇒ bot
Constructor Details
#initialize(config, criterion) ⇒ CoverageCriterion
Returns a new instance of CoverageCriterion.
94 95 96 97 |
# File 'lib/simplecov/configuration/coverage.rb', line 94 def initialize(config, criterion) @config = config @criterion = criterion end |
Instance Method Details
#exact(percent) ⇒ void
This method returns an undefined value.
113 114 115 116 |
# File 'lib/simplecov/configuration/coverage.rb', line 113 def exact(percent) minimum(percent) maximum(percent) end |
#group(name) ⇒ GroupTarget
134 135 136 |
# File 'lib/simplecov/configuration/coverage.rb', line 134 def group(name) GroupTarget.new(name: name) end |
#ignore(*types) ⇒ Array[Symbol]
The flatten serves the one-liner keyword form, whose value arrives as a
single argument (ignore: %i[implicit_else]).
140 141 142 143 144 145 146 147 148 |
# File 'lib/simplecov/configuration/coverage.rb', line 140 def ignore(*types) case @criterion when :branch then @config.__send__(:store_ignored_branches, types.flatten) when :method then @config.__send__(:store_ignored_methods, types.flatten) else raise ConfigurationError, "`ignore` is supported for `coverage :branch` and `coverage :method`, not #{@criterion.inspect}" end end |
#maximum(percent) ⇒ void
This method returns an undefined value.
109 110 111 |
# File 'lib/simplecov/configuration/coverage.rb', line 109 def maximum(percent) @config.__send__(:store_overall_threshold, :maximum_coverage, @criterion, percent) end |
#maximum_drop(percent) ⇒ void
This method returns an undefined value.
118 119 120 |
# File 'lib/simplecov/configuration/coverage.rb', line 118 def maximum_drop(percent) @config.__send__(:store_overall_threshold, :maximum_coverage_drop, @criterion, percent) end |
#maximum_missed(count, per: nil) ⇒ void
This method returns an undefined value.
122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/simplecov/configuration/coverage.rb', line 122 def maximum_missed(count, per: nil) case per when nil then @config.__send__(:store_missed_cap, :maximum_missed, @criterion, count) when :file then @config.__send__(:store_maximum_missed_per_file, @criterion, count, nil) when String, Regexp then @config.__send__(:store_maximum_missed_per_file, @criterion, count, per) when GroupTarget raise ConfigurationError, "maximum_missed does not support `per: group(...)` yet; see docs/Roadmap.md" else raise_invalid_per(per) end end |
#maximum_missed_per_file(count, only: nil) ⇒ void
This method returns an undefined value.
162 163 164 165 166 |
# File 'lib/simplecov/configuration/coverage.rb', line 162 def maximum_missed_per_file(count, only: nil) Deprecation.warn("`maximum_missed_per_file` is deprecated. " \ "Replace with `maximum_missed #{count}, per: #{(only || :file).inspect}`.") @config.__send__(:store_maximum_missed_per_file, @criterion, count, only) end |
#minimum(percent, per: nil) ⇒ void
This method returns an undefined value.
99 100 101 102 103 104 105 106 107 |
# File 'lib/simplecov/configuration/coverage.rb', line 99 def minimum(percent, per: nil) case per when nil then @config.__send__(:store_overall_threshold, :minimum_coverage, @criterion, percent) when :file then @config.__send__(:store_minimum_per_file, @criterion, percent, nil) when String, Regexp then @config.__send__(:store_minimum_per_file, @criterion, percent, per) when GroupTarget then @config.__send__(:store_minimum_per_group, @criterion, percent, per.name) else raise_invalid_per(per) end end |
#minimum_per_file(percent, only: nil) ⇒ void
This method returns an undefined value.
150 151 152 153 154 |
# File 'lib/simplecov/configuration/coverage.rb', line 150 def minimum_per_file(percent, only: nil) Deprecation.warn("`minimum_per_file` is deprecated. " \ "Replace with `minimum #{percent}, per: #{(only || :file).inspect}`.") @config.__send__(:store_minimum_per_file, @criterion, percent, only) end |
#minimum_per_group(percent, only:) ⇒ void
This method returns an undefined value.
156 157 158 159 160 |
# File 'lib/simplecov/configuration/coverage.rb', line 156 def minimum_per_group(percent, only:) Deprecation.warn("`minimum_per_group` is deprecated. " \ "Replace with `minimum #{percent}, per: group(#{only.inspect})`.") @config.__send__(:store_minimum_per_group, @criterion, percent, only) end |
#primary ⇒ void
This method returns an undefined value.
168 169 170 171 172 |
# File 'lib/simplecov/configuration/coverage.rb', line 168 def primary # @criterion is Symbol-wide because this receiver is also built for # :eval; primary_coverage validates at runtime. @config.primary_coverage(_ = @criterion) end |
#raise_invalid_per(per) ⇒ bot
178 179 180 181 |
# File 'lib/simplecov/configuration/coverage.rb', line 178 def raise_invalid_per(per) raise ConfigurationError, "`per:` must be :file, a String path, a Regexp, or group(\"Name\"), got #{per.inspect}" end |