Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Remove reponsibilities from Mutant::Runner

* Mutant filtering and subject gathering is now injected
  • Loading branch information...
commit b7113adbfb7bf210f1149b4bc679cc4982733ad0 1 parent d62754d
Markus Schirp authored
Showing with 18 additions and 47 deletions.
  1. +18 −47 lib/mutant/runner.rb
View
65 lib/mutant/runner.rb
@@ -45,14 +45,25 @@ def reporter; @reporter; end
# @api private
#
def initialize(options)
- @killer = Helper.extract_option(options, :killer)
- @pattern = Helper.extract_option(options, :pattern)
- @reporter = options.fetch(:reporter, Reporter::Null)
+ @killer = Helper.extract_option(options, :killer)
+ @matcher = Helper.extract_option(options, :matcher)
+ @reporter = options.fetch(:reporter, Reporter::Null)
+ @mutation_filter = options.fetch(:mutation_filter, Mutation::Filter::ALL)
@errors = []
run
end
+ # Return subject enumerator
+ #
+ # @return [Enumerator<Subject>]
+ #
+ # @api private
+ #
+ def subjects
+ @matcher.each
+ end
+
# Run mutation killers on subjects
#
# @return [undefined]
@@ -60,7 +71,7 @@ def initialize(options)
# @api private
#
def run
- @subjects = subjects.each do |subject|
+ subjects.each do |subject|
reporter.subject(subject)
run_subject(subject)
end
@@ -76,6 +87,7 @@ def run
#
def run_subject(subject)
subject.each do |mutation|
+ next unless @mutation_filter.match?(mutation)
reporter.mutation(mutation)
kill(mutation)
end
@@ -97,6 +109,8 @@ def kill(mutation)
@errors << killer
end
end
+ end
+end
# Return candiate matcher enumerator
#
@@ -107,46 +121,3 @@ def kill(mutation)
def candidate_matchers
[Matcher::Method::Singleton, Matcher::Method::Instance].each
end
-
- # Return candidats enumerator
- #
- # @return [Enumerable<Object>]
- #
- # @api private
- #
- def candidates
- return to_enum(__method__) unless block_given?
- ObjectSpace.each_object(Module) do |candidate|
- yield candidate if @pattern =~ candidate.name and [::Module,::Class].include?(candidate.class)
- end
- end
-
- # Return matcher enumerator
- #
- # @return [Enumerable<Matcher>]
- #
- # @api private
- #
- def matchers(&block)
- return to_enum(__method__) unless block_given?
- candidate_matchers.each do |candidate_matcher|
- candidates.each do |candidate|
- candidate_matcher.each(candidate,&block)
- end
- end
- end
-
- # Return subjects enumerator
- #
- # @return [Enumerable<Subject>]
- #
- # @api private
- #
- def subjects(&block)
- return to_enum(__method__) unless block_given?
- matchers.each do |matcher|
- matcher.each(&block)
- end
- end
- end
-end

0 comments on commit b7113ad

Please sign in to comment.
Something went wrong with that request. Please try again.