Class: Mutant::Config Private
- Inherits:
-
Object
- Object
- Mutant::Config
- Includes:
- Unparser::Adamantium
- Defined in:
- lib/mutant.rb,
lib/mutant/config.rb,
lib/mutant/config/coverage_criteria.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Standalone configuration of a mutant execution.
Does not reference any “external” volatile state. The configuration applied to current environment is being represented by the Mutant::Env object.
rubocop:disable Metrics/ClassLength
Defined Under Namespace
Classes: CoverageCriteria
Constant Summary collapse
- DEFAULT =
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.
new( coverage_criteria: Config::CoverageCriteria::EMPTY, expression_parser: Expression::Parser.new([ Expression::Descendants, Expression::Method, Expression::Methods, Expression::Namespace::Exact, Expression::Namespace::Recursive ]), fail_fast: false, environment_variables: EMPTY_HASH, hooks: EMPTY_ARRAY, includes: EMPTY_ARRAY, integration: nil, isolation: Mutant::Isolation::Fork.new(WORLD), jobs: nil, matcher: Matcher::Config::DEFAULT, mutation_timeout: nil, reporter: Reporter::CLI.build(WORLD.stdout), requires: EMPTY_ARRAY, zombie: false )
- MORE_THAN_ONE_CONFIG_FILE =
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.
<<~'MESSAGE' Found more than one candidate for use as implicit config file: %s MESSAGE
- CANDIDATES =
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.
%w[ .mutant.yml config/mutant.yml mutant.yml ].freeze
- PATHNAME_ARRAY =
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.
Transform::Array.new( Transform::Sequence.new( [ Transform::STRING, Transform::Exception.new(ArgumentError, Pathname.public_method(:new)) ] ) )
Class Method Summary collapse
-
.env ⇒ Config
private
The configuration from the environment.
-
.load_config_file(world) ⇒ Either<String,Config>
private
Load config file.
-
.parse_environment_variables(hash) ⇒ Either<String,Hash<String,String>]
private
Parse a hash of environment variables.
Instance Method Summary collapse
-
#expand_defaults ⇒ Config
private
Expand config with defaults.
-
#merge(other) ⇒ Config
private
Merge with other config.
Class Method Details
.env ⇒ Config
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.
The configuration from the environment
111 112 113 |
# File 'lib/mutant/config.rb', line 111 def self.env DEFAULT.with(jobs: Etc.nprocessors) end |
.load_config_file(world) ⇒ Either<String,Config>
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.
Load config file
76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/mutant/config.rb', line 76 def self.load_config_file(world) files = CANDIDATES .map(&world.pathname.public_method(:new)) .select(&:readable?) if files.one? load_contents(files.first).fmap(&DEFAULT.public_method(:with)) elsif files.empty? Either::Right.new(DEFAULT) else Either::Left.new(MORE_THAN_ONE_CONFIG_FILE % files.join(', ')) end end |
.parse_environment_variables(hash) ⇒ Either<String,Hash<String,String>]
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 hash of environment variables
130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/mutant/config.rb', line 130 def self.parse_environment_variables(hash) invalid = hash.keys.reject { |key| key.instance_of?(String) } return Either::Left.new("Non string keys: #{invalid}") if invalid.any? invalid = hash.keys.grep_v(ENV_VARIABLE_KEY_REGEXP) return Either::Left.new("Invalid keys: #{invalid}") if invalid.any? invalid = hash.values.reject { |value| value.instance_of?(String) } return Either::Left.new("Non string values: #{invalid}") if invalid.any? Either::Right.new(hash) end |
Instance Method Details
#expand_defaults ⇒ Config
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.
Expand config with defaults
93 94 95 96 97 98 |
# File 'lib/mutant/config.rb', line 93 def with( coverage_criteria: CoverageCriteria::DEFAULT.merge(coverage_criteria), jobs: jobs || 1 ) end |
#merge(other) ⇒ Config
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.
Merge with other config
rubocop:disable Metrics/AbcSize rubocop:disable Metrics/MethodLength
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/mutant/config.rb', line 52 def merge(other) other.with( coverage_criteria: coverage_criteria.merge(other.coverage_criteria), environment_variables: environment_variables.merge(other.environment_variables), fail_fast: fail_fast || other.fail_fast, hooks: hooks + other.hooks, includes: includes + other.includes, integration: other.integration || integration, jobs: other.jobs || jobs, matcher: matcher.merge(other.matcher), mutation_timeout: other.mutation_timeout || mutation_timeout, requires: requires + other.requires, zombie: zombie || other.zombie ) end |