Method: Hanami::Utils::Files.write

Defined in:
lib/hanami/utils/files.rb

.write(path, *content) ⇒ Object

Creates a new file for the given path and content. All the intermediate directories are created.

Parameters:

  • path (String, Pathname)

    the path to file

  • content (String, Array<String>)

    the content to write

Since:

  • 1.1.0



32
33
34
35
36
# File 'lib/hanami/utils/files.rb', line 32

def self.write(path, *content)
  mkdir_p(path)
  # This isn't a call to `::Kernel.open`, but to `self.open`
  open(path, ::File::CREAT | ::File::WRONLY | ::File::TRUNC, *content) # rubocop:disable Security/Open
end