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
|
|
|
|
@cache[path] = Parser::CurrentRuby.parse(File.read(path))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end # Cache
|
|
|
|
end # Mutant
|