Move complex matcher building out of CLI responsibilities

This commit is contained in:
Markus Schirp 2014-06-27 16:07:45 +00:00
parent c183652488
commit 0203fbf03d
3 changed files with 8 additions and 7 deletions

View file

@ -195,6 +195,7 @@ require 'mutant/subject/method'
require 'mutant/subject/method/instance' require 'mutant/subject/method/instance'
require 'mutant/subject/method/singleton' require 'mutant/subject/method/singleton'
require 'mutant/matcher' require 'mutant/matcher'
require 'mutant/matcher/builder'
require 'mutant/matcher/chain' require 'mutant/matcher/chain'
require 'mutant/matcher/method' require 'mutant/matcher/method'
require 'mutant/matcher/method/finder' require 'mutant/matcher/method/finder'
@ -217,7 +218,6 @@ require 'mutant/runner/subject'
require 'mutant/runner/mutation' require 'mutant/runner/mutation'
require 'mutant/runner/killer' require 'mutant/runner/killer'
require 'mutant/cli' require 'mutant/cli'
require 'mutant/cli/builder'
require 'mutant/color' require 'mutant/color'
require 'mutant/diff' require 'mutant/diff'
require 'mutant/reporter' require 'mutant/reporter'

View file

@ -39,7 +39,7 @@ module Mutant
# @api private # @api private
# #
def initialize(arguments = []) def initialize(arguments = [])
@builder = Builder.new @builder = Matcher::Builder.new
@debug = @fail_fast = @zombie = false @debug = @fail_fast = @zombie = false
@expected_coverage = 100.0 @expected_coverage = 100.0
@strategy = Strategy::Null.new @strategy = Strategy::Null.new
@ -101,13 +101,14 @@ module Mutant
# Parse matchers # Parse matchers
# #
# @param [Enumerable<String>] patterns # @param [Array<String>] patterns
# #
# @return [undefined] # @return [undefined]
# #
# @api private # @api private
# #
def parse_matchers(patterns) def parse_matchers(patterns)
raise Error, 'No patterns given' if patterns.empty?
patterns.each do |pattern| patterns.each do |pattern|
expression = Expression.parse(pattern) expression = Expression.parse(pattern)
unless expression unless expression

View file

@ -1,6 +1,6 @@
module Mutant module Mutant
class CLI class Matcher
# Builder for configuration components # Builder for complex matchers
class Builder class Builder
include NodeHelpers include NodeHelpers
@ -63,7 +63,7 @@ module Mutant
# #
def matcher def matcher
if @matchers.empty? if @matchers.empty?
raise(Error, 'No patterns given') return Matcher::Null.new
end end
matcher = Matcher::Chain.build(@matchers) matcher = Matcher::Chain.build(@matchers)
@ -135,5 +135,5 @@ module Mutant
end end
end # Builder end # Builder
end # CLI end # Matcher
end # Mutant end # Mutant