Method: Ronin::DB::ConfigFile.edit

Defined in:
lib/ronin/db/config_file.rb

.edit(path = PATH) {|yaml| ... } ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Opens the configuration file and edits it's contents.

Yields:

  • (yaml)

    The given block will be given the loaded configuration data. Once the block has returned, the YAML configuration data will be written back to the file.

Yield Parameters:

  • yaml (YAML::Store)

    The loaded YAML configuration data.



127
128
129
130
131
132
133
134
135
# File 'lib/ronin/db/config_file.rb', line 127

def self.edit(path=PATH,&block)
  unless File.file?(path)
    # create the parent directory for YAML::Store
    FileUtils.mkdir_p(File.dirname(path))
  end

  store = YAML::Store.new(path)
  store.transaction(&block)
end