free_mutant/lib/mutant/parser.rb
2018-09-12 13:15:43 +00:00

25 lines
439 B
Ruby

# frozen_string_literal: true
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