Sha256: f0a0813cd880bcaeb5ce37bca6898c4089bfa487a0a9dd193a4b168714424aa3
Contents?: true
Size: 621 Bytes
Versions: 9
Compression:
Stored size: 621 Bytes
Contents
module Pansophy module Local class CreateFile include Adamantium::Flat def initialize(path, body) @pathname = Pathname.new(path) @body = body end def call(options = {}) prevent_overwrite! unless options[:overwrite] @pathname.dirname.mkpath ::File.open(@pathname, 'wb') do |f| f.write @body end end private def prevent_overwrite! return unless @pathname.exist? fail ArgumentError, "#{@pathname} already exists, pass ':overwrite => true' to overwrite" end end end end
Version data entries
9 entries across 9 versions & 1 rubygems