Sha256: 4de72313936f90a6f59802f115f2233ec5e1f41f0f33f15dfe4769dd1850bbd2

Contents?: true

Size: 492 Bytes

Versions: 1

Compression:

Stored size: 492 Bytes

Contents

require "writer/file_namer"

module Writer
  class FileCreator
    class << self
      def create!(filename, content = nil)
        create_file(filename, content)
        File.open(filename, '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.3.1 lib/writer/file_creator.rb