17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/deprecation_toolkit/read_write_helper.rb', line 17
def write(deprecation_file, deprecations_to_record)
original_deprecations = deprecation_file.exist? ? YAML.load_file(deprecation_file) : {}
updated_deprecations = original_deprecations.dup
deprecations_to_record.each do |test, deprecation_to_record|
if deprecation_to_record.any?
updated_deprecations[test] = deprecation_to_record
else
updated_deprecations.delete(test)
end
end
if updated_deprecations.any?
if updated_deprecations != original_deprecations
deprecation_file.dirname.mkpath
deprecation_file.write(YAML.dump(updated_deprecations.sort.to_h))
end
elsif deprecation_file.exist?
deprecation_file.delete
end
end
|