2018-09-12 14:21:24 +00:00
|
|
|
# frozen_string_literal: true
|
2018-09-12 13:15:43 +00:00
|
|
|
|
2015-11-13 04:47:47 +00:00
|
|
|
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
|