Class: Mutant::Config Private

Inherits:
Object
  • Object
show all
Includes:
Adamantium::Flat
Defined in:
lib/mutant.rb,
lib/mutant/config.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.

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(
  expression_parser: Expression::Parser.new([
    Expression::Method,
    Expression::Methods,
    Expression::Namespace::Exact,
    Expression::Namespace::Recursive
  ]),
  fail_fast:         false,
  includes:          EMPTY_ARRAY,
  integration:       'null',
  isolation:         Mutant::Isolation::Fork.new(WORLD),
  jobs:              Etc.nprocessors,
  matcher:           Matcher::Config::DEFAULT,
  reporter:          Reporter::CLI.build(WORLD.stdout),
  requires:          EMPTY_ARRAY,
  zombie:            false
)
TRANSFORM =

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::Sequence.new(
  [
    Transform::Exception.new(SystemCallError, :read.to_proc),
    Transform::Exception.new(YAML::SyntaxError, YAML.method(:safe_load)),
    Transform::Hash.new(
      optional: [
        Transform::Hash::Key.new('fail_fast',   boolean),
        Transform::Hash::Key.new('includes',    string_array),
        Transform::Hash::Key.new('integration', string),
        Transform::Hash::Key.new('jobs',        integer),
        Transform::Hash::Key.new('requires',    string_array)
      ],
      required: []
    ),
    Transform::Hash::Symbolize.new
  ]
)
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

Class Method Summary collapse

Class Method Details

.load_config_file(world, config) ⇒ 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

Parameters:

Returns:



117
118
119
120
121
122
123
124
125
126
127
# File 'lib/mutant/config.rb', line 117

def self.load_config_file(world, config)
  files = CANDIDATES.map(&world.pathname.method(:new)).select(&:readable?)

  if files.one?
    load_contents(files.first).fmap(&config.method(:with))
  elsif files.empty?
    Either::Right.new(config)
  else
    Either::Left.new(MORE_THAN_ONE_CONFIG_FILE % files.join(', '))
  end
end