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:



125
126
127
128
# File 'lib/simplecov/configuration/coverage.rb', line 125

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)


142
143
144
145
# File 'lib/simplecov/configuration/coverage.rb', line 142

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)


137
138
139
# File 'lib/simplecov/configuration/coverage.rb', line 137

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)


148
149
150
# File 'lib/simplecov/configuration/coverage.rb', line 148

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)


131
132
133
# File 'lib/simplecov/configuration/coverage.rb', line 131

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)


155
156
157
# File 'lib/simplecov/configuration/coverage.rb', line 155

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)


160
161
162
# File 'lib/simplecov/configuration/coverage.rb', line 160

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.



165
166
167
168
169
# File 'lib/simplecov/configuration/coverage.rb', line 165

def primary
  # @criterion is Symbol-wide because this receiver is also built for
  # :eval; primary_coverage validates at runtime.
  @config.primary_coverage(_ = @criterion)
end