free_mutant/lib/mutant/cache.rb
Markus Schirp 3390abc675 Use environment object inside matchers
This will allow to use reporters from matchers avoiding stupid direct
writes to $stderr.

Also it will allow to remove matching from CLI altogether in a phase of
the runner. Allowing to decouple Mutant::Config from VM environment
allowing to serialize it ;)

Step by step. Takes a while.
2014-06-30 13:08:52 +00:00

31 lines
508 B
Ruby

module Mutant
# An AST cache
class Cache
include Equalizer.new, Adamantium::Mutable
# Initialize object
#
# @return [undefined]
#
# @api private
#
def initialize
@cache = {}
end
# Return node for file
#
# @param [#to_s] path
#
# @return [AST::Node]
#
# @api private
#
def parse(path)
@cache.fetch(path) do
@cache[path] = Parser::CurrentRuby.parse(File.read(path))
end
end
end # Cache
end # Mutant