2012-07-23 16:54:35 -04:00
|
|
|
module Mutant
|
2012-07-26 13:25:23 -04:00
|
|
|
# Abstract matcher to find ASTs to mutate
|
2012-07-23 16:54:35 -04:00
|
|
|
class Matcher
|
2012-11-02 21:12:33 -04:00
|
|
|
include Adamantium::Flat, Enumerable, AbstractClass
|
2012-08-28 13:54:28 -04:00
|
|
|
extend DescendantsTracker
|
2012-07-23 16:54:35 -04:00
|
|
|
|
2012-08-01 12:34:03 -04:00
|
|
|
# Enumerate subjects
|
2012-07-23 16:54:35 -04:00
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
2012-07-23 19:41:08 -04:00
|
|
|
# @return [undefined]
|
|
|
|
#
|
2012-08-02 19:28:15 -04:00
|
|
|
abstract_method :each
|
2012-07-26 13:25:23 -04:00
|
|
|
|
2012-08-15 22:10:54 -04:00
|
|
|
# Return identification
|
|
|
|
#
|
|
|
|
# @return [String
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
|
|
|
abstract_method :identification
|
|
|
|
|
2012-08-28 13:54:28 -04:00
|
|
|
# Return matcher
|
|
|
|
#
|
|
|
|
# @param [String] input
|
|
|
|
#
|
|
|
|
# @return [nil]
|
|
|
|
# returns nil as default implementation
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
|
|
|
def self.parse(input)
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
|
|
|
|
# Return match from string
|
|
|
|
#
|
|
|
|
# @param [String] input
|
|
|
|
#
|
|
|
|
# @return [Matcher]
|
|
|
|
# returns matcher input if successful
|
|
|
|
#
|
|
|
|
# @return [nil]
|
|
|
|
# returns nil otherwise
|
|
|
|
#
|
|
|
|
def self.from_string(input)
|
|
|
|
descendants.each do |descendant|
|
|
|
|
matcher = descendant.parse(input)
|
|
|
|
return matcher if matcher
|
|
|
|
end
|
2012-07-26 13:25:23 -04:00
|
|
|
|
2012-08-28 13:54:28 -04:00
|
|
|
nil
|
|
|
|
end
|
2012-07-23 16:54:35 -04:00
|
|
|
end
|
|
|
|
end
|