mirror of
https://github.com/samsonjs/samhuri.net.git
synced 2026-03-25 09:05:47 +00:00
21 lines
477 B
Ruby
21 lines
477 B
Ruby
require 'fileutils'
|
|
|
|
module Pressa
|
|
module Utils
|
|
class FileWriter
|
|
def self.write(path:, content:, permissions: 0o644)
|
|
FileUtils.mkdir_p(File.dirname(path))
|
|
|
|
File.write(path, content, mode: 'w')
|
|
File.chmod(permissions, path)
|
|
end
|
|
|
|
def self.write_data(path:, data:, permissions: 0o644)
|
|
FileUtils.mkdir_p(File.dirname(path))
|
|
|
|
File.binwrite(path, data)
|
|
File.chmod(permissions, path)
|
|
end
|
|
end
|
|
end
|
|
end
|