Method: Ruber::DocumentProject::Backend#write
- Defined in:
- lib/ruber/document_project.rb
#write(opts) ⇒ Object
Works mostly as YamlSettingsBackend#write. If the only option to be written is the project name, the file isn’t created, if it doesn’t exist, and is deleted if it does exist. Also, if there are any obsolete files (see document_path=), they are deleted, too.
If no file name is associated with the backend (that is, if file returns an empty string), a SystemCall error (most likely, Errno::ENOENT) will be raised
73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/ruber/document_project.rb', line 73 def write opts new_data = compute_data opts if new_data.has_only_keys?(:general) and new_data[:general].has_only_keys?(:project_name) FileUtils.rm_f @filename return end File.open(@filename, 'w'){|f| f.write YAML.dump(new_data)} @old_files.each{|f| FileUtils.rm_f f} @old_files.clear @data = new_data end |