Sha256: 4cc8f2efac5517f11c51897b69f1dc2a5d801538b4a25279a44b033b55d85d10

Contents?: true

Size: 419 Bytes

Versions: 1

Compression:

Stored size: 419 Bytes

Contents

require_relative "stupid_file_writer/version"
require 'fileutils'

module StupidFileWriter
  def self.write(path, content)
    create(path) if is_path?(path) && !File.exist?(path)
    file = File.open(path, 'w')
    file.print content
    file.close
  end

  def self.create(path)
    path = path.split('/')[0..-2].join('/')
    FileUtils.mkdir_p(path)
  end

  def self.is_path?(path)
    path.include?('/')
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
stupid_file_writer-0.1.1 lib/stupid_file_writer.rb