lib/mutant/bootstrap.rb in mutant-0.9.8 vs lib/mutant/bootstrap.rb in mutant-0.9.9
- old
+ new
@@ -47,46 +47,28 @@
)
end
end
# rubocop:enable Metrics/MethodLength
- # Infect environment
- #
- # @return [undefined]
def self.infect(env)
config, world = env.config, env.world
config.includes.each(&world.load_path.method(:<<))
config.requires.each(&world.kernel.method(:require))
end
private_class_method :infect
- # Matchable scopes
- #
- # @param [World] world
- # @param [Config] config
- #
- # @return [Array<Scope>]
def self.matchable_scopes(world, config)
scopes = world.object_space.each_object(Module).each_with_object([]) do |scope, aggregate|
expression = expression(config.reporter, config.expression_parser, scope) || next
aggregate << Scope.new(scope, expression)
end
scopes.sort_by { |scope| scope.expression.syntax }
end
private_class_method :matchable_scopes
- # Scope name from scoping object
- #
- # @param [Class, Module] scope
- #
- # @return [String]
- # if scope has a name and does not raise exceptions obtaining it
- #
- # @return [nil]
- # otherwise
def self.scope_name(reporter, scope)
scope.name
rescue => exception
semantics_warning(
reporter,
@@ -97,24 +79,11 @@
)
nil
end
private_class_method :scope_name
- # Try to turn scope into expression
- #
- # @param [Expression::Parser] expression_parser
- # @param [Class, Module] scope
- #
- # @return [Expression]
- # if scope can be represented in an expression
- #
- # @return [nil]
- # otherwise
- #
# rubocop:disable Metrics/MethodLength
- #
- # ignore :reek:LongParameterList
def self.expression(reporter, expression_parser, scope)
name = scope_name(reporter, scope) or return
unless name.instance_of?(String)
semantics_warning(
@@ -130,14 +99,9 @@
expression_parser.apply(name).from_right {}
end
private_class_method :expression
# rubocop:enable Metrics/MethodLength
- # Write a semantics warning
- #
- # @return [undefined]
- #
- # ignore :reek:LongParameterList
def self.semantics_warning(reporter, format, options)
reporter.warn(SEMANTICS_MESSAGE_FORMAT % { message: format % options })
end
private_class_method :semantics_warning
end # Bootstrap