Class: SimpleCov::Configuration::CoverageCriterion

Inherits:
Object
  • Object
show all
Defined in:
lib/simplecov/configuration/coverage.rb,
sig/simplecov.rbs

Overview

Receiver for a coverage <criterion> do ... end block. Each verb writes a threshold for the single criterion the block configures, so values are always plain percentages.

Instance Method Summary collapse

Constructor Details

#initialize(config, criterion) ⇒ CoverageCriterion

Returns a new instance of CoverageCriterion.

Parameters:



128
129
130
131
# File 'lib/simplecov/configuration/coverage.rb', line 128

def initialize(config, criterion)
  @config = config
  @criterion = criterion
end

Instance Method Details

#exact(percent) ⇒ void

This method returns an undefined value.

Pin coverage to an exact figure (sets both minimum and maximum).

Parameters:

  • percent (Numeric)


145
146
147
148
# File 'lib/simplecov/configuration/coverage.rb', line 145

def exact(percent)
  minimum(percent)
  maximum(percent)
end

#maximum(percent) ⇒ void

This method returns an undefined value.

Overall maximum: fails the build if coverage rises above it.

Parameters:

  • percent (Numeric)


140
141
142
# File 'lib/simplecov/configuration/coverage.rb', line 140

def maximum(percent)
  @config.send(:store_overall_threshold, :maximum_coverage, @criterion, percent)
end

#maximum_drop(percent) ⇒ void

This method returns an undefined value.

Maximum allowed drop between runs (0 refuses any drop).

Parameters:

  • percent (Numeric)


151
152
153
# File 'lib/simplecov/configuration/coverage.rb', line 151

def maximum_drop(percent)
  @config.send(:store_overall_threshold, :maximum_coverage_drop, @criterion, percent)
end

#minimum(percent) ⇒ void

This method returns an undefined value.

Overall (suite-wide) minimum for this criterion.

Parameters:

  • percent (Numeric)


134
135
136
# File 'lib/simplecov/configuration/coverage.rb', line 134

def minimum(percent)
  @config.send(:store_overall_threshold, :minimum_coverage, @criterion, percent)
end

#minimum_per_file(percent, only: nil) ⇒ void

This method returns an undefined value.

Per-file minimum. With no only:, the default for every file; with only: (String path or Regexp), an override for matches.

Parameters:

  • percent (Numeric)
  • only: (String, Regexp, nil) (defaults to: nil)


158
159
160
# File 'lib/simplecov/configuration/coverage.rb', line 158

def minimum_per_file(percent, only: nil)
  @config.send(:store_minimum_per_file, @criterion, percent, only)
end

#minimum_per_group(percent, only:) ⇒ void

This method returns an undefined value.

Per-group minimum for the named group (defined via group).

Parameters:

  • percent (Numeric)
  • only: (String)


163
164
165
# File 'lib/simplecov/configuration/coverage.rb', line 163

def minimum_per_group(percent, only:)
  @config.send(:store_minimum_per_group, @criterion, percent, only)
end

#primaryvoid

This method returns an undefined value.

Make this criterion the report's primary (leading) criterion.



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