Sha256: 2902734bd0234bd7bc811da60b25b739e57b87d14db329c9c446efb7b7f73678
Contents?: true
Size: 580 Bytes
Versions: 13
Compression:
Stored size: 580 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.write(@pathname, @body) 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
13 entries across 13 versions & 1 rubygems