free_mutant/lib/mutant/cache.rb
Dan Kubb 7293386c26 Add magic encoding header to all ruby files
* rubocop still warns about this on ruby 1.9.3, so it was fixed so
  it produces less output on travis.
2013-07-28 16:03:06 -07:00

32 lines
549 B
Ruby

# encoding: utf-8
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