Class: Mutant::Cache

Inherits:
Object
  • Object
show all
Defined in:
lib/mutant/cache.rb

Overview

An AST cache

Instance Method Summary collapse

Constructor Details

#initializeundefined

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initialize object



15
16
17
# File 'lib/mutant/cache.rb', line 15

def initialize
  @cache = {}
end

Instance Method Details

#parse(path) ⇒ AST::Node

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return node for file

Returns:

  • (AST::Node)


25
26
27
28
29
# File 'lib/mutant/cache.rb', line 25

def parse(path)
  @cache.fetch(path) do
    @cache[path] = Parser::CurrentRuby.parse(File.read(path))
  end
end