-
Notifications
You must be signed in to change notification settings - Fork 133
/
checker.ex
29 lines (24 loc) · 835 Bytes
/
checker.ex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
defmodule ExVCR.Checker do
@moduledoc """
Provides data store for checking which cassette files are used.
It's for [mix vcr.check] task.
"""
use ExActor.GenServer, export: :singleton
defstart start(arg), do: initial_state(arg)
defcall get, state: state, do: reply(state)
defcast set(x), do: new_state(x)
defcast append(x), state: state, do: new_state(%{state | files: [x|state.files]})
@doc """
Increment the counter for cache cassettes hit.
"""
def add_cache_count(recorder), do: add_count(recorder, :cache)
@doc """
Increment the counter for server request hit.
"""
def add_server_count(recorder), do: add_count(recorder, :server)
defp add_count(recorder, type) do
if ExVCR.Checker.get != [] do
ExVCR.Checker.append({type, ExVCR.Recorder.get_file_path(recorder)})
end
end
end