Module: DeprecationToolkit::ReadWriteHelper
- Included in:
- Behaviors::Record, Collector
- Defined in:
- lib/deprecation_toolkit/read_write_helper.rb
Instance Method Summary collapse
Instance Method Details
#read(test) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/deprecation_toolkit/read_write_helper.rb', line 9 def read(test) deprecation_file = recorded_deprecations_path(test) YAML.load(deprecation_file.read).fetch(test.name, []) rescue Errno::ENOENT [] end |
#write(test, deprecations) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/deprecation_toolkit/read_write_helper.rb', line 16 def write(test, deprecations) deprecation_file = recorded_deprecations_path(test) create_deprecation_file(deprecation_file) unless deprecation_file.exist? content = YAML.load_file(deprecation_file) if deprecations.any? content[test.name] = deprecations else content.delete(test.name) end if content.any? deprecation_file.write(YAML.dump(content)) else deprecation_file.delete end end |