Class: Cucover::Store

Inherits:
Object
  • Object
show all
Defined in:
lib/cucover/store.rb

Defined Under Namespace

Classes: DiskCache, Recordings

Instance Method Summary collapse

Constructor Details

#initialize(cache = DiskCache.new) ⇒ Store

Returns a new instance of Store.



3
4
5
# File 'lib/cucover/store.rb', line 3

def initialize(cache = DiskCache.new)
  @cache = cache
end

Instance Method Details

#keep!(recording_data) ⇒ Object



15
16
17
18
19
# File 'lib/cucover/store.rb', line 15

def keep!(recording_data)
  Cucover.logger.debug("Storing recording of #{recording_data.file_colon_line}")
  recordings[recording_data.file_colon_line] << recording_data
  @cache.save(@recordings)
end

#latest_recording(file_colon_line) ⇒ Object



11
12
13
# File 'lib/cucover/store.rb', line 11

def latest_recording(file_colon_line)
  recordings[file_colon_line].sort{ |x, y| x.end_time <=> y.end_time }.last
end

#latest_recordingsObject



7
8
9
# File 'lib/cucover/store.rb', line 7

def latest_recordings
  recordings.keys.map{ |file_colon_line| latest_recording(file_colon_line) }
end

#recordingsObject



25
26
27
28
# File 'lib/cucover/store.rb', line 25

def recordings
  ensure_recordings_loaded!
  @recordings
end

#recordings_covering(source_file) ⇒ Object



21
22
23
# File 'lib/cucover/store.rb', line 21

def recordings_covering(source_file)
  latest_recordings.select { |r| r.covers_file?(source_file) }
end