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