Method: VScripts::Util::LocalSystem#write_file

Defined in:
lib/vscripts/util/local_system.rb

#write_file(file, body) ⇒ Object

Writes to a file

Parameters:

  • file (String)

    the path of the file

  • body (String)

    the body of the file



52
53
54
55
56
57
58
59
# File 'lib/vscripts/util/local_system.rb', line 52

def write_file(file, body)
  ensure_file_dir(file)
  File.open(file, 'w') do |newfile|
    newfile.write(body)
  end
rescue Errno::EACCES
  abort "FATAL: You need to be root in order to write to #{file}"
end