
This avoids situartions where the source contains (begin, other) nodes that get mutated to (other) where there is no difference in the source. Closes #198
32 lines
577 B
Ruby
32 lines
577 B
Ruby
# encoding: utf-8
|
|
|
|
module Mutant
|
|
# An AST cache
|
|
class Cache
|
|
# This is explicitly empty! Ask me if you are interested in reasons :D
|
|
include Equalizer.new
|
|
|
|
# Initialize object
|
|
#
|
|
# @return [undefined]
|
|
#
|
|
# @api private
|
|
#
|
|
def initialize
|
|
@cache = {}
|
|
end
|
|
|
|
# Return node for file
|
|
#
|
|
# @return [AST::Node]
|
|
#
|
|
# @api private
|
|
#
|
|
def parse(path)
|
|
@cache.fetch(path) do
|
|
@cache[path] = Unparser::Preprocessor.run(Parser::CurrentRuby.parse(File.read(path)))
|
|
end
|
|
end
|
|
|
|
end # Cache
|
|
end # Mutant
|