lib/mutant/config.rb in mutant-0.10.4 vs lib/mutant/config.rb in mutant-0.10.5
- old
+ new
@@ -1,57 +1,8 @@
# frozen_string_literal: true
module Mutant
- # The outer world IO objects mutant does interact with
- class World
- include Adamantium::Flat, Anima.new(
- :condition_variable,
- :gem,
- :gem_method,
- :io,
- :json,
- :kernel,
- :load_path,
- :marshal,
- :mutex,
- :object_space,
- :open3,
- :pathname,
- :process,
- :stderr,
- :stdout,
- :thread,
- :warnings
- )
-
- INSPECT = '#<Mutant::World>'
-
- private_constant(*constants(false))
-
- # Object inspection
- #
- # @return [String]
- def inspect
- INSPECT
- end
-
- # Capture stdout of a command
- #
- # @param [Array<String>] command
- #
- # @return [Either<String,String>]
- def capture_stdout(command)
- stdout, status = open3.capture2(*command, binmode: true)
-
- if status.success?
- Either::Right.new(stdout)
- else
- Either::Left.new("Command #{command} failed!")
- end
- end
- end # World
-
# 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.
class Config
@@ -104,23 +55,41 @@
.mutant.yml
config/mutant.yml
mutant.yml
].freeze
+ # Merge with other config
+ #
+ # @param [Config] other
+ #
+ # @return [Config]
+ def merge(other)
+ other.with(
+ fail_fast: fail_fast || other.fail_fast,
+ includes: includes + other.includes,
+ jobs: other.jobs || jobs,
+ integration: other.integration || integration,
+ matcher: matcher.merge(other.matcher),
+ requires: requires + other.requires,
+ zombie: zombie || other.zombie
+ )
+ end
+
private_constant(*constants(false))
# Load config file
#
# @param [World] world
# @param [Config] config
#
# @return [Either<String,Config>]
- def self.load_config_file(world, config)
- files = CANDIDATES.map(&world.pathname.method(:new)).select(&:readable?)
+ def self.load_config_file(world)
+ config = DEFAULT
+ files = CANDIDATES.map(&world.pathname.public_method(:new)).select(&:readable?)
if files.one?
- load_contents(files.first).fmap(&config.method(:with))
+ load_contents(files.first).fmap(&config.public_method(:with))
elsif files.empty?
Either::Right.new(config)
else
Either::Left.new(MORE_THAN_ONE_CONFIG_FILE % files.join(', '))
end
@@ -131,7 +100,14 @@
.new(path.to_s, TRANSFORM)
.apply(path)
.lmap(&:compact_message)
end
private_class_method :load_contents
+
+ # The configuration from the environment
+ #
+ # @return [Config]
+ def self.env
+ DEFAULT.with(jobs: Etc.nprocessors)
+ end
end # Config
end # Mutant