diff --git a/config/flay.yml b/config/flay.yml index 8137c434..0f268fdd 100644 --- a/config/flay.yml +++ b/config/flay.yml @@ -1,3 +1,3 @@ --- threshold: 18 -total_score: 293 +total_score: 296 diff --git a/lib/mutant/helper.rb b/lib/mutant/helper.rb index 5802bcd2..355e775c 100644 --- a/lib/mutant/helper.rb +++ b/lib/mutant/helper.rb @@ -33,5 +33,20 @@ module Mutant RUBY_VERSION == '1.8.7' end + # Extract option from options hash + # + # @param [Hash] options + # @param [Object] key + # + # @return [Object] value + # + # @api private + # + def self.extract_option(options, key) + options.fetch(key) do + raise ArgumentError,"Missing #{key.inspect} in options" + end + end + end end diff --git a/lib/mutant/runner.rb b/lib/mutant/runner.rb index eadac00d..2e6be4bf 100644 --- a/lib/mutant/runner.rb +++ b/lib/mutant/runner.rb @@ -46,16 +46,11 @@ module Mutant # @api private # def initialize(options) - @killer = options.fetch(:killer) do - raise ArgumentError, 'Missing :killer in options' - end - - @pattern = options.fetch(:pattern) do - raise ArgumentError, 'Missing :pattern in options' - end - + @killer = Helper.extract_option(options, :killer) + @pattern = Helper.extract_option(options, :pattern) @reporter = options.fetch(:reporter, Reporter::Null) @errors = [] + run end