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

[View source]

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

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