/*1Copyright (c) 2012, Yahoo! Inc. All rights reserved.2Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.3*/45var util = require('util'),6EventEmitter = require('events').EventEmitter;78function extend(cons, proto) {9Object.keys(proto).forEach(function (k) {10cons.prototype[k] = proto[k];11});12}1314/**15* abstract interfaces for writing content16* @class ContentWriter17* @module io18* @main io19* @constructor20*/21//abstract interface for writing content22function ContentWriter() {23}2425ContentWriter.prototype = {26/**27* writes the specified string as-is28* @method write29* @param {String} str the string to write30*/31write: /* istanbul ignore next: abstract method */ function (/* str */) {32throw new Error('write: must be overridden');33},34/**35* writes the specified string with a newline at the end36* @method println37* @param {String} str the string to write38*/39println: function (str) { this.write(str + '\n'); }40};4142/**43* abstract interface for writing files and assets. The caller is expected to44* call `done` on the writer after it has finished writing all the required45* files. The writer is an event-emitter that emits a `done` event when `done`46* is called on it *and* all files have successfully been written.47*48* @class Writer49* @constructor50*/51function Writer() {52EventEmitter.call(this);53}5455util.inherits(Writer, EventEmitter);5657extend(Writer, {58/**59* allows writing content to a file using a callback that is passed a content writer60* @method writeFile61* @param {String} file the name of the file to write62* @param {Function} callback the callback that is called as `callback(contentWriter)`63*/64writeFile: /* istanbul ignore next: abstract method */ function (/* file, callback */) {65throw new Error('writeFile: must be overridden');66},67/**68* copies a file from source to destination69* @method copyFile70* @param {String} source the file to copy, found on the file system71* @param {String} dest the destination path72*/73copyFile: /* istanbul ignore next: abstract method */ function (/* source, dest */) {74throw new Error('copyFile: must be overridden');75},76/**77* marker method to indicate that the caller is done with this writer object78* The writer is expected to emit a `done` event only after this method is called79* and it is truly done.80* @method done81*/82done: /* istanbul ignore next: abstract method */ function () {83throw new Error('done: must be overridden');84}85});8687module.exports = {88Writer: Writer,89ContentWriter: ContentWriter90};91929394