class Mutest::Matcher::Method::Evaluator
Abstract method match evaluator
Present to avoid passing the env argument around in case the logic would be implemented directly on the Matcher::Method
instance
Public Instance Methods
call()
click to toggle source
Matched subjects
@return [Enumerable<Subject>]
# File lib/mutest/matcher/method.rb, line 43 def call return EMPTY_ARRAY if skip? [subject].compact end
Private Instance Methods
ast()
click to toggle source
Root source node
@return [Parser::AST::Node]
# File lib/mutest/matcher/method.rb, line 80 def ast source_file.ast end
context()
click to toggle source
Target context
@return [Context]
# File lib/mutest/matcher/method.rb, line 73 def context Context.new(scope, source_file) end
matched_node_path()
click to toggle source
Matched node path
@return [Array<Parser::AST::Node>]
# File lib/mutest/matcher/method.rb, line 127 def matched_node_path AST.find_last_path(ast, &method(:match?)) end
method_name()
click to toggle source
Target method name
@return [String]
# File lib/mutest/matcher/method.rb, line 66 def method_name target_method.name end
skip?()
click to toggle source
Test
if method should be skipped
@return [Truthy]
# File lib/mutest/matcher/method.rb, line 54 def skip? location = source_location if location.nil? || BLACKLIST.match(location.first) env.warn(SOURCE_LOCATION_WARNING_FORMAT % target_method) elsif matched_node_path.any?(&method(:n_block?)) env.warn(CLOSURE_WARNING_FORMAT % target_method) end end
source_file()
click to toggle source
# File lib/mutest/matcher/method.rb, line 84 def source_file env.parser.open(source_path) end
source_line()
click to toggle source
Source file line
@return [Integer]
# File lib/mutest/matcher/method.rb, line 100 def source_line source_location.last end
source_location()
click to toggle source
Full source location
@return [Array<String,Integer>]
# File lib/mutest/matcher/method.rb, line 107 def source_location target_method.source_location end
source_path()
click to toggle source
Path to source
@return [Pathname]
# File lib/mutest/matcher/method.rb, line 92 def source_path env.config.pathname.new(source_location.first) end
subject()
click to toggle source
Matched subject
@return [Subject]
if there is a matched node
@return [nil]
otherwise
# File lib/mutest/matcher/method.rb, line 118 def subject node = matched_node_path.last || return self.class::SUBJECT_CLASS.new(context, node) end