12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/concurrent_pipeline/stores/yaml.rb', line 12
def self.build_writer(data:, dir:, registry:)
data_path = File.join(dir, "data.yml")
versions_path = File.join(dir, "versions.yml")
after_apply = ->(changesets) do
File.write(data_path, data.to_yaml)
File.open(versions_path, "a") do |f|
changesets
.map { _1.as_json.to_yaml }
.join("\n")
.then { f.puts(_1)}
end
end
db = Db.new(data: data, registry: registry, after_apply: after_apply)
changeset = db.changeset
changeset.deltas << Changeset::InitialDelta.new(data: data)
db.apply(changeset)
db
end
|