Sha256: 6903706f0363134530286de67d608426712fef7d35e0b4a9a2a4d2ed189c8964

Contents?: true

Size: 567 Bytes

Versions: 1

Compression:

Stored size: 567 Bytes

Contents

require "writer/overwrite_prevention"

module Writer
  class FileCreator
    class << self
      def create!(filename, content)
        name = OverwritePrevention.adjust(filename)
        content = content

        create_file(name, content)
        File.open(name, 'r')
      end

      private
      def create_file(name, content)
        File.open(name, 'w') do |f|
          f.puts content || template
        end
      end

      def template
        if Writer.template_path
          File.open(Writer.template_path).read
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
writer-0.1.1 lib/writer/file_creator.rb