Class: Ruptr::TimingCache

Inherits:
Object
  • Object
show all
Defined in:
lib/ruptr/timing_cache.rb

Defined Under Namespace

Classes: Store

Constant Summary collapse

TIMING_CACHE_FILENAME =
'timing'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(state_dir, test_suite) ⇒ TimingCache

Returns a new instance of TimingCache.



12
13
14
15
# File 'lib/ruptr/timing_cache.rb', line 12

def initialize(state_dir, test_suite)
  @state_path = Pathname(state_dir)
  @test_suite = test_suite
end

Instance Attribute Details

#test_suiteObject (readonly)

Returns the value of attribute test_suite.



17
18
19
# File 'lib/ruptr/timing_cache.rb', line 17

def test_suite
  @test_suite
end

Instance Method Details

#save!(replace: true) ⇒ Object



30
31
32
33
# File 'lib/ruptr/timing_cache.rb', line 30

def save!(replace: true)
  return unless @timing_store
  @timing_store.dump(@test_suite, @cache_path, replace:)
end

#timing_storeObject



19
20
21
22
23
24
25
26
27
28
# File 'lib/ruptr/timing_cache.rb', line 19

def timing_store
  @timing_store ||= begin
    @cache_path = @state_path / TIMING_CACHE_FILENAME
    if @cache_path.exist?
      TimingCache::Store.load(@test_suite, @cache_path)
    else
      TimingCache::Store.new
    end
  end
end