Method: File.open!

Defined in:
lib/yard/core_ext/file.rb

.open!(file, *args, &block) ⇒ Object

Forces opening a file (for writing) by first creating the file’s directory

Parameters:

  • file (String)

    the filename to open

Since:

  • 0.5.2



57
58
59
60
61
# File 'lib/yard/core_ext/file.rb', line 57

def self.open!(file, *args, &block)
  dir = dirname(file)
  FileUtils.mkdir_p(dir) unless directory?(dir)
  open(file, *args, &block)
end