Class: Rematch

Inherits:
Object
  • Object
show all
Defined in:
lib/rematch.rb,
lib/rematch/tasks.rb

Overview

Implement the key/value store

Defined Under Namespace

Modules: Tasks

Constant Summary collapse

VERSION =
'0.0.1'
EXT =
'.rematch'

Instance Method Summary collapse

Constructor Details

#initialize(path:, id:) ⇒ Rematch

path and unique id of the test being run



12
13
14
15
16
# File 'lib/rematch.rb', line 12

def initialize(path:, id:)
  @store = YAML::Store.new("#{path}#{EXT}", true)
  @id    = id
  @count = 0
end

Instance Method Details

#rematch(value) ⇒ Object

store if unknown; retrieve otherwise



19
20
21
22
# File 'lib/rematch.rb', line 19

def rematch(value)
  key = "[#{@count += 1}] #{@id}"
  @store.transaction { |s| s.root?(key) ? s[key] : s[key] = value }
end