free_mutant/lib/mutant/parser.rb

24 lines
408 B
Ruby
Raw Normal View History

module Mutant
# An AST Parser
class Parser
include Adamantium::Mutable, Equalizer.new
# Initialize object
#
# @return [undefined]
def initialize
@cache = {}
end
# Parse path into AST
#
# @param [Pathname] path
#
# @return [AST::Node]
def call(path)
@cache[path] ||= ::Parser::CurrentRuby.parse(path.read)
end
end # Parser
end # Mutant