Class: Evilution::SpecAstCache Private

Inherits:
Object
  • Object
show all
Defined in:
lib/evilution/spec_ast_cache.rb

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

Defined Under Namespace

Classes: Block

Instance Method Summary collapse

Constructor Details

#initialize(max_files: DEFAULT_MAX_FILES, max_blocks: DEFAULT_MAX_BLOCKS) ⇒ SpecAstCache

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.

Returns a new instance of SpecAstCache.



20
21
22
23
24
25
# File 'lib/evilution/spec_ast_cache.rb', line 20

def initialize(max_files: DEFAULT_MAX_FILES, max_blocks: DEFAULT_MAX_BLOCKS)
  @max_files = max_files
  @max_blocks = max_blocks
  @entries = {}
  @total_blocks = 0
end

Instance Method Details

#cached?(path) ⇒ Boolean

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.

Returns:

  • (Boolean)


39
40
41
# File 'lib/evilution/spec_ast_cache.rb', line 39

def cached?(path)
  @entries.key?(path)
end

#fetch(path) ⇒ Object

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.



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/evilution/spec_ast_cache.rb', line 27

def fetch(path)
  if @entries.key?(path)
    blocks = @entries.delete(path)
    @entries[path] = blocks
    return blocks
  end

  blocks = parse(path)
  insert(path, blocks)
  blocks
end