Module: SimpleCov::RSpec::ListUncoveredOption Private
- Defined in:
- lib/simplecov-rspec/list_uncovered_option.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Resolves the list_uncovered: option (plus its LIST_UNCOVERED ENV override)
into a normalized Array
Constant Summary collapse
- ALL_CRITERIA =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
The coverage criteria this gem knows how to report on
%i[line branch method].freeze
- ALL_ENV_VALUES =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
LIST_UNCOVERED environment variable values that mean "every criterion"
%w[yes on true 1 all].freeze
- NONE_ENV_VALUES =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
LIST_UNCOVERED environment variable values that mean "no criteria"
%w[false no off 0].freeze
Class Method Summary collapse
-
.from_env(raw) ⇒ false, ...
private
Parse a raw LIST_UNCOVERED environment variable value.
-
.normalize(value) ⇒ Array<Symbol>
private
Normalize a
list_uncovered:-style value into an Array of Symbols. -
.resolve(value, env:, env_var:) ⇒ Array<Symbol>
private
Resolve the effective criteria, applying the ENV override if present.
-
.validate(criteria) ⇒ Array<Symbol>
private
Raise unless every given criterion is one this gem knows how to report on.
Class Method Details
.from_env(raw) ⇒ false, ...
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Parse a raw LIST_UNCOVERED environment variable value
40 41 42 43 44 45 46 |
# File 'lib/simplecov-rspec/list_uncovered_option.rb', line 40 def from_env(raw) raw = raw.strip.downcase return false if raw.empty? || NONE_ENV_VALUES.include?(raw) return :all if ALL_ENV_VALUES.include?(raw) raw.split(',').map { |criterion| criterion.strip.to_sym } end |
.normalize(value) ⇒ Array<Symbol>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Normalize a list_uncovered:-style value into an Array of Symbols
53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/simplecov-rspec/list_uncovered_option.rb', line 53 def normalize(value) case value when nil, false then [] when :all then ALL_CRITERIA when Symbol then validate([value]) when Array then validate(value) else raise ArgumentError, "list_uncovered must be false, :all, a Symbol, or an Array of Symbols; got #{value.inspect}" end end |
.resolve(value, env:, env_var:) ⇒ Array<Symbol>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Resolve the effective criteria, applying the ENV override if present
30 31 32 33 |
# File 'lib/simplecov-rspec/list_uncovered_option.rb', line 30 def resolve(value, env:, env_var:) value = from_env(env.fetch(env_var)) if env.key?(env_var) ALL_CRITERIA & normalize(value) end |
.validate(criteria) ⇒ Array<Symbol>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Raise unless every given criterion is one this gem knows how to report on
71 72 73 74 75 76 |
# File 'lib/simplecov-rspec/list_uncovered_option.rb', line 71 def validate(criteria) invalid = criteria - ALL_CRITERIA return criteria if invalid.empty? raise ArgumentError, "Unknown coverage criterion #{invalid.inspect}; must be one of #{ALL_CRITERIA.inspect}" end |