class Rematch

Implement the key/value store

Constants

EXT
VERSION

Attributes

rebuild[RW]

Public Class Methods

check_rebuild(path) click to toggle source
# File lib/rematch.rb, line 16
def check_rebuild(path)
  return unless @rebuild && !@rebuilt.include?(path)

  FileUtils.rm_f(path)
  @rebuilt << path
  puts "Rebuilt #{path}"
end
new(path:, id:) click to toggle source

path and unique id of the test being run

# File lib/rematch.rb, line 26
def initialize(path:, id:)
  path = "#{path}#{EXT}"
  self.class.check_rebuild(path)
  @store = YAML::Store.new(path, true)
  @id    = id
  @count = 0
end

Public Instance Methods

rematch(value) click to toggle source

store if unknown; retrieve otherwise

# File lib/rematch.rb, line 35
def rematch(value)
  key = "[#{@count += 1}] #{@id}"
  @store.transaction { |s| s.root?(key) ? s[key] : s[key] = value }
end