Sha256: 38128a7f8f16aae4b9d1f181c89f563630f7ad88323fcdfe0c3e00540b5dde9e
Contents?: true
Size: 485 Bytes
Versions: 15
Compression:
Stored size: 485 Bytes
Contents
# encoding: utf-8 require 'fileutils' module FileHelper def create_file(file_path, content) file_path = File.expand_path(file_path) dir_path = File.dirname(file_path) FileUtils.makedirs dir_path unless File.exist?(dir_path) File.open(file_path, 'w') do |file| case content when '' # Write nothing. Create empty file. when String file.puts content when Array file.puts content.join("\n") end end end end
Version data entries
15 entries across 15 versions & 2 rubygems