2013-07-28 19:03:06 -04:00
|
|
|
# encoding: utf-8
|
|
|
|
|
2013-06-27 16:18:07 -04:00
|
|
|
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
|
2014-06-08 07:42:53 -04:00
|
|
|
@cache[path] = Unparser::Preprocessor.run(Parser::CurrentRuby.parse(File.read(path)))
|
2013-06-27 16:18:07 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end # Cache
|
|
|
|
end # Mutant
|