Sha256: 85e98d755d5ea8af885c490265dd27aee1a903c0e13306d473e57223f09d333a

Contents?: true

Size: 418 Bytes

Versions: 2

Compression:

Stored size: 418 Bytes

Contents

module Writer
  class FileCreator
    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
      unless Writer.template_path.blank?
        File.open(Writer.template_path).read
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
writer-0.4.0.1 lib/writer/file_creator.rb
writer-0.4.0 lib/writer/file_creator.rb