diff options
Diffstat (limited to 'node_modules/xmlbuilder/lib')
22 files changed, 552 insertions, 1583 deletions
diff --git a/node_modules/xmlbuilder/lib/Utility.js b/node_modules/xmlbuilder/lib/Utility.js deleted file mode 100644 index aca1d1e44..000000000 --- a/node_modules/xmlbuilder/lib/Utility.js +++ /dev/null @@ -1,139 +0,0 @@ -// Generated by CoffeeScript 1.10.0 -(function() { - var assign, camelCase, capitalize, isArray, isEmpty, isFunction, isObject, isPlainObject, kebabCase, snakeCase, titleCase, words, - slice = [].slice, - hasProp = {}.hasOwnProperty; - - assign = function() { - var i, key, len, source, sources, target; - target = arguments[0], sources = 2 <= arguments.length ? slice.call(arguments, 1) : []; - if (isFunction(Object.assign)) { - Object.assign.apply(null, arguments); - } else { - for (i = 0, len = sources.length; i < len; i++) { - source = sources[i]; - if (source != null) { - for (key in source) { - if (!hasProp.call(source, key)) continue; - target[key] = source[key]; - } - } - } - } - return target; - }; - - isFunction = function(val) { - return !!val && Object.prototype.toString.call(val) === '[object Function]'; - }; - - isObject = function(val) { - var ref; - return !!val && ((ref = typeof val) === 'function' || ref === 'object'); - }; - - isArray = function(val) { - if (isFunction(Array.isArray)) { - return Array.isArray(val); - } else { - return Object.prototype.toString.call(val) === '[object Array]'; - } - }; - - isEmpty = function(val) { - var key; - if (isArray(val)) { - return !val.length; - } else { - for (key in val) { - if (!hasProp.call(val, key)) continue; - return false; - } - return true; - } - }; - - isPlainObject = function(val) { - var ctor, proto; - return isObject(val) && (proto = Object.getPrototypeOf(val)) && (ctor = proto.constructor) && (typeof ctor === 'function') && (ctor instanceof ctor) && (Function.prototype.toString.call(ctor) === Function.prototype.toString.call(Object)); - }; - - words = function(val) { - return (val.split(/[-_\s]+|(?=[A-Z][a-z])/) || []).filter(function(n) { - return !!n; - }); - }; - - camelCase = function(val) { - var i, index, len, r, ref, word; - r = ''; - ref = words(val); - for (index = i = 0, len = ref.length; i < len; index = ++i) { - word = ref[index]; - r += index ? capitalize(word.toLowerCase()) : word.toLowerCase(); - } - return r; - }; - - titleCase = function(val) { - var i, index, len, r, ref, word; - r = ''; - ref = words(val); - for (index = i = 0, len = ref.length; i < len; index = ++i) { - word = ref[index]; - r += capitalize(word.toLowerCase()); - } - return r; - }; - - kebabCase = function(val) { - var i, index, len, r, ref, word; - r = ''; - ref = words(val); - for (index = i = 0, len = ref.length; i < len; index = ++i) { - word = ref[index]; - r += (index ? '-' : '') + word.toLowerCase(); - } - return r; - }; - - snakeCase = function(val) { - var i, index, len, r, ref, word; - r = ''; - ref = words(val); - for (index = i = 0, len = ref.length; i < len; index = ++i) { - word = ref[index]; - r += (index ? '_' : '') + word.toLowerCase(); - } - return r; - }; - - capitalize = function(val) { - return val.charAt(0).toUpperCase() + val.slice(1); - }; - - module.exports.assign = assign; - - module.exports.isFunction = isFunction; - - module.exports.isObject = isObject; - - module.exports.isArray = isArray; - - module.exports.isEmpty = isEmpty; - - module.exports.isPlainObject = isPlainObject; - - module.exports.camelCase = camelCase; - - module.exports.titleCase = titleCase; - - module.exports.kebabCase = kebabCase; - - module.exports.snakeCase = snakeCase; - - module.exports.capitalize = capitalize; - - module.exports.words = words; - -}).call(this); diff --git a/node_modules/xmlbuilder/lib/XMLAttribute.js b/node_modules/xmlbuilder/lib/XMLAttribute.js index 51ccebe52..f6c6bd8d0 100644 --- a/node_modules/xmlbuilder/lib/XMLAttribute.js +++ b/node_modules/xmlbuilder/lib/XMLAttribute.js @@ -1,10 +1,11 @@ -// Generated by CoffeeScript 1.10.0 +// Generated by CoffeeScript 1.9.1 (function() { - var XMLAttribute; + var XMLAttribute, create; + + create = require('lodash/create'); module.exports = XMLAttribute = (function() { function XMLAttribute(parent, name, value) { - this.options = parent.options; this.stringify = parent.stringify; if (name == null) { throw new Error("Missing attribute name of element " + parent.name); @@ -17,11 +18,11 @@ } XMLAttribute.prototype.clone = function() { - return Object.create(this); + return create(XMLAttribute.prototype, this); }; - XMLAttribute.prototype.toString = function(options) { - return this.options.writer.set(options).attribute(this); + XMLAttribute.prototype.toString = function(options, level) { + return ' ' + this.name + '="' + this.value + '"'; }; return XMLAttribute; diff --git a/node_modules/xmlbuilder/lib/XMLCData.js b/node_modules/xmlbuilder/lib/XMLCData.js index 8ee861d50..c171a28c9 100644 --- a/node_modules/xmlbuilder/lib/XMLCData.js +++ b/node_modules/xmlbuilder/lib/XMLCData.js @@ -1,9 +1,11 @@ -// Generated by CoffeeScript 1.10.0 +// Generated by CoffeeScript 1.9.1 (function() { - var XMLCData, XMLNode, + var XMLCData, XMLNode, create, extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, hasProp = {}.hasOwnProperty; + create = require('lodash/create'); + XMLNode = require('./XMLNode'); module.exports = XMLCData = (function(superClass) { @@ -18,11 +20,26 @@ } XMLCData.prototype.clone = function() { - return Object.create(this); + return create(XMLCData.prototype, this); }; - XMLCData.prototype.toString = function(options) { - return this.options.writer.set(options).cdata(this); + XMLCData.prototype.toString = function(options, level) { + var indent, newline, offset, pretty, r, ref, ref1, ref2, space; + pretty = (options != null ? options.pretty : void 0) || false; + indent = (ref = options != null ? options.indent : void 0) != null ? ref : ' '; + offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0; + newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n'; + level || (level = 0); + space = new Array(level + offset + 1).join(indent); + r = ''; + if (pretty) { + r += space; + } + r += '<![CDATA[' + this.text + ']]>'; + if (pretty) { + r += newline; + } + return r; }; return XMLCData; diff --git a/node_modules/xmlbuilder/lib/XMLComment.js b/node_modules/xmlbuilder/lib/XMLComment.js index 2c987a35f..ca801f65d 100644 --- a/node_modules/xmlbuilder/lib/XMLComment.js +++ b/node_modules/xmlbuilder/lib/XMLComment.js @@ -1,9 +1,11 @@ -// Generated by CoffeeScript 1.10.0 +// Generated by CoffeeScript 1.9.1 (function() { - var XMLComment, XMLNode, + var XMLComment, XMLNode, create, extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, hasProp = {}.hasOwnProperty; + create = require('lodash/create'); + XMLNode = require('./XMLNode'); module.exports = XMLComment = (function(superClass) { @@ -18,11 +20,26 @@ } XMLComment.prototype.clone = function() { - return Object.create(this); + return create(XMLComment.prototype, this); }; - XMLComment.prototype.toString = function(options) { - return this.options.writer.set(options).comment(this); + XMLComment.prototype.toString = function(options, level) { + var indent, newline, offset, pretty, r, ref, ref1, ref2, space; + pretty = (options != null ? options.pretty : void 0) || false; + indent = (ref = options != null ? options.indent : void 0) != null ? ref : ' '; + offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0; + newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n'; + level || (level = 0); + space = new Array(level + offset + 1).join(indent); + r = ''; + if (pretty) { + r += space; + } + r += '<!-- ' + this.text + ' -->'; + if (pretty) { + r += newline; + } + return r; }; return XMLComment; diff --git a/node_modules/xmlbuilder/lib/XMLDTDAttList.js b/node_modules/xmlbuilder/lib/XMLDTDAttList.js index 1d7e18e3a..4a71866f7 100644 --- a/node_modules/xmlbuilder/lib/XMLDTDAttList.js +++ b/node_modules/xmlbuilder/lib/XMLDTDAttList.js @@ -1,16 +1,12 @@ -// Generated by CoffeeScript 1.10.0 +// Generated by CoffeeScript 1.9.1 (function() { - var XMLDTDAttList, XMLNode, - extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, - hasProp = {}.hasOwnProperty; + var XMLDTDAttList, create; - XMLNode = require('./XMLNode'); - - module.exports = XMLDTDAttList = (function(superClass) { - extend(XMLDTDAttList, superClass); + create = require('lodash/create'); + module.exports = XMLDTDAttList = (function() { function XMLDTDAttList(parent, elementName, attributeName, attributeType, defaultValueType, defaultValue) { - XMLDTDAttList.__super__.constructor.call(this, parent); + this.stringify = parent.stringify; if (elementName == null) { throw new Error("Missing DTD element name"); } @@ -39,12 +35,34 @@ this.defaultValueType = defaultValueType; } - XMLDTDAttList.prototype.toString = function(options) { - return this.options.writer.set(options).dtdAttList(this); + XMLDTDAttList.prototype.toString = function(options, level) { + var indent, newline, offset, pretty, r, ref, ref1, ref2, space; + pretty = (options != null ? options.pretty : void 0) || false; + indent = (ref = options != null ? options.indent : void 0) != null ? ref : ' '; + offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0; + newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n'; + level || (level = 0); + space = new Array(level + offset + 1).join(indent); + r = ''; + if (pretty) { + r += space; + } + r += '<!ATTLIST ' + this.elementName + ' ' + this.attributeName + ' ' + this.attributeType; + if (this.defaultValueType !== '#DEFAULT') { + r += ' ' + this.defaultValueType; + } + if (this.defaultValue) { + r += ' "' + this.defaultValue + '"'; + } + r += '>'; + if (pretty) { + r += newline; + } + return r; }; return XMLDTDAttList; - })(XMLNode); + })(); }).call(this); diff --git a/node_modules/xmlbuilder/lib/XMLDTDElement.js b/node_modules/xmlbuilder/lib/XMLDTDElement.js index d2067713d..0002c1bdf 100644 --- a/node_modules/xmlbuilder/lib/XMLDTDElement.js +++ b/node_modules/xmlbuilder/lib/XMLDTDElement.js @@ -1,16 +1,12 @@ -// Generated by CoffeeScript 1.10.0 +// Generated by CoffeeScript 1.9.1 (function() { - var XMLDTDElement, XMLNode, - extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, - hasProp = {}.hasOwnProperty; + var XMLDTDElement, create; - XMLNode = require('./XMLNode'); - - module.exports = XMLDTDElement = (function(superClass) { - extend(XMLDTDElement, superClass); + create = require('lodash/create'); + module.exports = XMLDTDElement = (function() { function XMLDTDElement(parent, name, value) { - XMLDTDElement.__super__.constructor.call(this, parent); + this.stringify = parent.stringify; if (name == null) { throw new Error("Missing DTD element name"); } @@ -24,12 +20,27 @@ this.value = this.stringify.dtdElementValue(value); } - XMLDTDElement.prototype.toString = function(options) { - return this.options.writer.set(options).dtdElement(this); + XMLDTDElement.prototype.toString = function(options, level) { + var indent, newline, offset, pretty, r, ref, ref1, ref2, space; + pretty = (options != null ? options.pretty : void 0) || false; + indent = (ref = options != null ? options.indent : void 0) != null ? ref : ' '; + offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0; + newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n'; + level || (level = 0); + space = new Array(level + offset + 1).join(indent); + r = ''; + if (pretty) { + r += space; + } + r += '<!ELEMENT ' + this.name + ' ' + this.value + '>'; + if (pretty) { + r += newline; + } + return r; }; return XMLDTDElement; - })(XMLNode); + })(); }).call(this); diff --git a/node_modules/xmlbuilder/lib/XMLDTDEntity.js b/node_modules/xmlbuilder/lib/XMLDTDEntity.js index 4cfd42287..f27d56799 100644 --- a/node_modules/xmlbuilder/lib/XMLDTDEntity.js +++ b/node_modules/xmlbuilder/lib/XMLDTDEntity.js @@ -1,18 +1,14 @@ -// Generated by CoffeeScript 1.10.0 +// Generated by CoffeeScript 1.9.1 (function() { - var XMLDTDEntity, XMLNode, isObject, - extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, - hasProp = {}.hasOwnProperty; + var XMLDTDEntity, create, isObject; - isObject = require('./Utility').isObject; + create = require('lodash/create'); - XMLNode = require('./XMLNode'); - - module.exports = XMLDTDEntity = (function(superClass) { - extend(XMLDTDEntity, superClass); + isObject = require('lodash/isObject'); + module.exports = XMLDTDEntity = (function() { function XMLDTDEntity(parent, pe, name, value) { - XMLDTDEntity.__super__.constructor.call(this, parent); + this.stringify = parent.stringify; if (name == null) { throw new Error("Missing entity name"); } @@ -45,12 +41,44 @@ } } - XMLDTDEntity.prototype.toString = function(options) { - return this.options.writer.set(options).dtdEntity(this); + XMLDTDEntity.prototype.toString = function(options, level) { + var indent, newline, offset, pretty, r, ref, ref1, ref2, space; + pretty = (options != null ? options.pretty : void 0) || false; + indent = (ref = options != null ? options.indent : void 0) != null ? ref : ' '; + offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0; + newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n'; + level || (level = 0); + space = new Array(level + offset + 1).join(indent); + r = ''; + if (pretty) { + r += space; + } + r += '<!ENTITY'; + if (this.pe) { + r += ' %'; + } + r += ' ' + this.name; + if (this.value) { + r += ' "' + this.value + '"'; + } else { + if (this.pubID && this.sysID) { + r += ' PUBLIC "' + this.pubID + '" "' + this.sysID + '"'; + } else if (this.sysID) { + r += ' SYSTEM "' + this.sysID + '"'; + } + if (this.nData) { + r += ' NDATA ' + this.nData; + } + } + r += '>'; + if (pretty) { + r += newline; + } + return r; }; return XMLDTDEntity; - })(XMLNode); + })(); }).call(this); diff --git a/node_modules/xmlbuilder/lib/XMLDTDNotation.js b/node_modules/xmlbuilder/lib/XMLDTDNotation.js index 8747d9dd8..edd3501fa 100644 --- a/node_modules/xmlbuilder/lib/XMLDTDNotation.js +++ b/node_modules/xmlbuilder/lib/XMLDTDNotation.js @@ -1,16 +1,12 @@ -// Generated by CoffeeScript 1.10.0 +// Generated by CoffeeScript 1.9.1 (function() { - var XMLDTDNotation, XMLNode, - extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, - hasProp = {}.hasOwnProperty; + var XMLDTDNotation, create; - XMLNode = require('./XMLNode'); - - module.exports = XMLDTDNotation = (function(superClass) { - extend(XMLDTDNotation, superClass); + create = require('lodash/create'); + module.exports = XMLDTDNotation = (function() { function XMLDTDNotation(parent, name, value) { - XMLDTDNotation.__super__.constructor.call(this, parent); + this.stringify = parent.stringify; if (name == null) { throw new Error("Missing notation name"); } @@ -26,12 +22,35 @@ } } - XMLDTDNotation.prototype.toString = function(options) { - return this.options.writer.set(options).dtdNotation(this); + XMLDTDNotation.prototype.toString = function(options, level) { + var indent, newline, offset, pretty, r, ref, ref1, ref2, space; + pretty = (options != null ? options.pretty : void 0) || false; + indent = (ref = options != null ? options.indent : void 0) != null ? ref : ' '; + offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0; + newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n'; + level || (level = 0); + space = new Array(level + offset + 1).join(indent); + r = ''; + if (pretty) { + r += space; + } + r += '<!NOTATION ' + this.name; + if (this.pubID && this.sysID) { + r += ' PUBLIC "' + this.pubID + '" "' + this.sysID + '"'; + } else if (this.pubID) { + r += ' PUBLIC "' + this.pubID + '"'; + } else if (this.sysID) { + r += ' SYSTEM "' + this.sysID + '"'; + } + r += '>'; + if (pretty) { + r += newline; + } + return r; }; return XMLDTDNotation; - })(XMLNode); + })(); }).call(this); diff --git a/node_modules/xmlbuilder/lib/XMLDeclaration.js b/node_modules/xmlbuilder/lib/XMLDeclaration.js index c8f2c06c6..b50289247 100644 --- a/node_modules/xmlbuilder/lib/XMLDeclaration.js +++ b/node_modules/xmlbuilder/lib/XMLDeclaration.js @@ -1,10 +1,12 @@ -// Generated by CoffeeScript 1.10.0 +// Generated by CoffeeScript 1.9.1 (function() { - var XMLDeclaration, XMLNode, isObject, + var XMLDeclaration, XMLNode, create, isObject, extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, hasProp = {}.hasOwnProperty; - isObject = require('./Utility').isObject; + create = require('lodash/create'); + + isObject = require('lodash/isObject'); XMLNode = require('./XMLNode'); @@ -29,8 +31,31 @@ } } - XMLDeclaration.prototype.toString = function(options) { - return this.options.writer.set(options).declaration(this); + XMLDeclaration.prototype.toString = function(options, level) { + var indent, newline, offset, pretty, r, ref, ref1, ref2, space; + pretty = (options != null ? options.pretty : void 0) || false; + indent = (ref = options != null ? options.indent : void 0) != null ? ref : ' '; + offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0; + newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n'; + level || (level = 0); + space = new Array(level + offset + 1).join(indent); + r = ''; + if (pretty) { + r += space; + } + r += '<?xml'; + r += ' version="' + this.version + '"'; + if (this.encoding != null) { + r += ' encoding="' + this.encoding + '"'; + } + if (this.standalone != null) { + r += ' standalone="' + this.standalone + '"'; + } + r += '?>'; + if (pretty) { + r += newline; + } + return r; }; return XMLDeclaration; diff --git a/node_modules/xmlbuilder/lib/XMLDocType.js b/node_modules/xmlbuilder/lib/XMLDocType.js index fa5e02028..cbc61b325 100644 --- a/node_modules/xmlbuilder/lib/XMLDocType.js +++ b/node_modules/xmlbuilder/lib/XMLDocType.js @@ -1,12 +1,14 @@ -// Generated by CoffeeScript 1.10.0 +// Generated by CoffeeScript 1.9.1 (function() { - var XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDocType, XMLNode, isObject, - extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, - hasProp = {}.hasOwnProperty; + var XMLCData, XMLComment, XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDocType, XMLProcessingInstruction, create, isObject; - isObject = require('./Utility').isObject; + create = require('lodash/create'); - XMLNode = require('./XMLNode'); + isObject = require('lodash/isObject'); + + XMLCData = require('./XMLCData'); + + XMLComment = require('./XMLComment'); XMLDTDAttList = require('./XMLDTDAttList'); @@ -16,13 +18,14 @@ XMLDTDNotation = require('./XMLDTDNotation'); - module.exports = XMLDocType = (function(superClass) { - extend(XMLDocType, superClass); + XMLProcessingInstruction = require('./XMLProcessingInstruction'); + module.exports = XMLDocType = (function() { function XMLDocType(parent, pubID, sysID) { var ref, ref1; - XMLDocType.__super__.constructor.call(this, parent); this.documentObject = parent; + this.stringify = this.documentObject.stringify; + this.children = []; if (isObject(pubID)) { ref = pubID, pubID = ref.pubID, sysID = ref.sysID; } @@ -72,8 +75,70 @@ return this; }; - XMLDocType.prototype.toString = function(options) { - return this.options.writer.set(options).docType(this); + XMLDocType.prototype.cdata = function(value) { + var child; + child = new XMLCData(this, value); + this.children.push(child); + return this; + }; + + XMLDocType.prototype.comment = function(value) { + var child; + child = new XMLComment(this, value); + this.children.push(child); + return this; + }; + + XMLDocType.prototype.instruction = function(target, value) { + var child; + child = new XMLProcessingInstruction(this, target, value); + this.children.push(child); + return this; + }; + + XMLDocType.prototype.root = function() { + return this.documentObject.root(); + }; + + XMLDocType.prototype.document = function() { + return this.documentObject; + }; + + XMLDocType.prototype.toString = function(options, level) { + var child, i, indent, len, newline, offset, pretty, r, ref, ref1, ref2, ref3, space; + pretty = (options != null ? options.pretty : void 0) || false; + indent = (ref = options != null ? options.indent : void 0) != null ? ref : ' '; + offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0; + newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n'; + level || (level = 0); + space = new Array(level + offset + 1).join(indent); + r = ''; + if (pretty) { + r += space; + } + r += '<!DOCTYPE ' + this.root().name; + if (this.pubID && this.sysID) { + r += ' PUBLIC "' + this.pubID + '" "' + this.sysID + '"'; + } else if (this.sysID) { + r += ' SYSTEM "' + this.sysID + '"'; + } + if (this.children.length > 0) { + r += ' ['; + if (pretty) { + r += newline; + } + ref3 = this.children; + for (i = 0, len = ref3.length; i < len; i++) { + child = ref3[i]; + r += child.toString(options, level + 1); + } + r += ']'; + } + r += '>'; + if (pretty) { + r += newline; + } + return r; }; XMLDocType.prototype.ele = function(name, value) { @@ -96,12 +161,28 @@ return this.notation(name, value); }; + XMLDocType.prototype.dat = function(value) { + return this.cdata(value); + }; + + XMLDocType.prototype.com = function(value) { + return this.comment(value); + }; + + XMLDocType.prototype.ins = function(target, value) { + return this.instruction(target, value); + }; + XMLDocType.prototype.up = function() { - return this.root() || this.documentObject; + return this.root(); + }; + + XMLDocType.prototype.doc = function() { + return this.document(); }; return XMLDocType; - })(XMLNode); + })(); }).call(this); diff --git a/node_modules/xmlbuilder/lib/XMLDocument.js b/node_modules/xmlbuilder/lib/XMLDocument.js deleted file mode 100644 index 2882faf2c..000000000 --- a/node_modules/xmlbuilder/lib/XMLDocument.js +++ /dev/null @@ -1,48 +0,0 @@ -// Generated by CoffeeScript 1.10.0 -(function() { - var XMLDocument, XMLNode, XMLStringWriter, XMLStringifier, isPlainObject, - extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, - hasProp = {}.hasOwnProperty; - - isPlainObject = require('./Utility').isPlainObject; - - XMLNode = require('./XMLNode'); - - XMLStringifier = require('./XMLStringifier'); - - XMLStringWriter = require('./XMLStringWriter'); - - module.exports = XMLDocument = (function(superClass) { - extend(XMLDocument, superClass); - - function XMLDocument(options) { - XMLDocument.__super__.constructor.call(this, null); - options || (options = {}); - if (!options.writer) { - options.writer = new XMLStringWriter(); - } - this.options = options; - this.stringify = new XMLStringifier(options); - this.isDocument = true; - } - - XMLDocument.prototype.end = function(writer) { - var writerOptions; - if (!writer) { - writer = this.options.writer; - } else if (isPlainObject(writer)) { - writerOptions = writer; - writer = this.options.writer.set(writerOptions); - } - return writer.document(this); - }; - - XMLDocument.prototype.toString = function(options) { - return this.options.writer.set(options).document(this); - }; - - return XMLDocument; - - })(XMLNode); - -}).call(this); diff --git a/node_modules/xmlbuilder/lib/XMLDocumentCB.js b/node_modules/xmlbuilder/lib/XMLDocumentCB.js deleted file mode 100644 index b8506e28f..000000000 --- a/node_modules/xmlbuilder/lib/XMLDocumentCB.js +++ /dev/null @@ -1,402 +0,0 @@ -// Generated by CoffeeScript 1.10.0 -(function() { - var XMLAttribute, XMLCData, XMLComment, XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDeclaration, XMLDocType, XMLDocumentCB, XMLElement, XMLProcessingInstruction, XMLRaw, XMLStringWriter, XMLStringifier, XMLText, isFunction, isObject, isPlainObject, ref, - hasProp = {}.hasOwnProperty; - - ref = require('./Utility'), isObject = ref.isObject, isFunction = ref.isFunction, isPlainObject = ref.isPlainObject; - - XMLElement = require('./XMLElement'); - - XMLCData = require('./XMLCData'); - - XMLComment = require('./XMLComment'); - - XMLRaw = require('./XMLRaw'); - - XMLText = require('./XMLText'); - - XMLProcessingInstruction = require('./XMLProcessingInstruction'); - - XMLDeclaration = require('./XMLDeclaration'); - - XMLDocType = require('./XMLDocType'); - - XMLDTDAttList = require('./XMLDTDAttList'); - - XMLDTDEntity = require('./XMLDTDEntity'); - - XMLDTDElement = require('./XMLDTDElement'); - - XMLDTDNotation = require('./XMLDTDNotation'); - - XMLAttribute = require('./XMLAttribute'); - - XMLStringifier = require('./XMLStringifier'); - - XMLStringWriter = require('./XMLStringWriter'); - - module.exports = XMLDocumentCB = (function() { - function XMLDocumentCB(options, onData, onEnd) { - var writerOptions; - options || (options = {}); - if (!options.writer) { - options.writer = new XMLStringWriter(options); - } else if (isPlainObject(options.writer)) { - writerOptions = options.writer; - options.writer = new XMLStringWriter(writerOptions); - } - this.options = options; - this.writer = options.writer; - this.stringify = new XMLStringifier(options); - this.onDataCallback = onData || function() {}; - this.onEndCallback = onEnd || function() {}; - this.currentNode = null; - this.currentLevel = -1; - this.openTags = {}; - this.documentStarted = false; - this.documentCompleted = false; - this.root = null; - } - - XMLDocumentCB.prototype.node = function(name, attributes, text) { - var ref1; - if (name == null) { - throw new Error("Missing node name"); - } - if (this.root && this.currentLevel === -1) { - throw new Error("Document can only have one root node"); - } - this.openCurrent(); - name = name.valueOf(); - if (attributes == null) { - attributes = {}; - } - attributes = attributes.valueOf(); - if (!isObject(attributes)) { - ref1 = [attributes, text], text = ref1[0], attributes = ref1[1]; - } - this.currentNode = new XMLElement(this, name, attributes); - this.currentNode.children = false; - this.currentLevel++; - this.openTags[this.currentLevel] = this.currentNode; - if (text != null) { - this.text(text); - } - return this; - }; - - XMLDocumentCB.prototype.element = function(name, attributes, text) { - if (this.currentNode && this.currentNode instanceof XMLDocType) { - return this.dtdElement.apply(this, arguments); - } else { - return this.node(name, attributes, text); - } - }; - - XMLDocumentCB.prototype.attribute = function(name, value) { - var attName, attValue; - if (!this.currentNode || this.currentNode.children) { - throw new Error("att() can only be used immediately after an ele() call in callback mode"); - } - if (name != null) { - name = name.valueOf(); - } - if (isObject(name)) { - for (attName in name) { - if (!hasProp.call(name, attName)) continue; - attValue = name[attName]; - this.attribute(attName, attValue); - } - } else { - if (isFunction(value)) { - value = value.apply(); - } - if (!this.options.skipNullAttributes || (value != null)) { - this.currentNode.attributes[name] = new XMLAttribute(this, name, value); - } - } - return this; - }; - - XMLDocumentCB.prototype.text = function(value) { - var node; - this.openCurrent(); - node = new XMLText(this, value); - this.onData(this.writer.text(node, this.currentLevel + 1)); - return this; - }; - - XMLDocumentCB.prototype.cdata = function(value) { - var node; - this.openCurrent(); - node = new XMLCData(this, value); - this.onData(this.writer.cdata(node, this.currentLevel + 1)); - return this; - }; - - XMLDocumentCB.prototype.comment = function(value) { - var node; - this.openCurrent(); - node = new XMLComment(this, value); - this.onData(this.writer.comment(node, this.currentLevel + 1)); - return this; - }; - - XMLDocumentCB.prototype.raw = function(value) { - var node; - this.openCurrent(); - node = new XMLRaw(this, value); - this.onData(this.writer.raw(node, this.currentLevel + 1)); - return this; - }; - - XMLDocumentCB.prototype.instruction = function(target, value) { - var i, insTarget, insValue, len, node; - this.openCurrent(); - if (target != null) { - target = target.valueOf(); - } - if (value != null) { - value = value.valueOf(); - } - if (Array.isArray(target)) { - for (i = 0, len = target.length; i < len; i++) { - insTarget = target[i]; - this.instruction(insTarget); - } - } else if (isObject(target)) { - for (insTarget in target) { - if (!hasProp.call(target, insTarget)) continue; - insValue = target[insTarget]; - this.instruction(insTarget, insValue); - } - } else { - if (isFunction(value)) { - value = value.apply(); - } - node = new XMLProcessingInstruction(this, target, value); - this.onData(this.writer.processingInstruction(node, this.currentLevel + 1)); - } - return this; - }; - - XMLDocumentCB.prototype.declaration = function(version, encoding, standalone) { - var node; - this.openCurrent(); - if (this.documentStarted) { - throw new Error("declaration() must be the first node"); - } - node = new XMLDeclaration(this, version, encoding, standalone); - this.onData(this.writer.declaration(node, this.currentLevel + 1)); - return this; - }; - - XMLDocumentCB.prototype.doctype = function(root, pubID, sysID) { - this.openCurrent(); - if (root == null) { - throw new Error("Missing root node name"); - } - if (this.root) { - throw new Error("dtd() must come before the root node"); - } - this.currentNode = new XMLDocType(this, pubID, sysID); - this.currentNode.rootNodeName = root; - this.currentNode.children = false; - this.currentLevel++; - this.openTags[this.currentLevel] = this.currentNode; - return this; - }; - - XMLDocumentCB.prototype.dtdElement = function(name, value) { - var node; - this.openCurrent(); - node = new XMLDTDElement(this, name, value); - this.onData(this.writer.dtdElement(node, this.currentLevel + 1)); - return this; - }; - - XMLDocumentCB.prototype.attList = function(elementName, attributeName, attributeType, defaultValueType, defaultValue) { - var node; - this.openCurrent(); - node = new XMLDTDAttList(this, elementName, attributeName, attributeType, defaultValueType, defaultValue); - this.onData(this.writer.dtdAttList(node, this.currentLevel + 1)); - return this; - }; - - XMLDocumentCB.prototype.entity = function(name, value) { - var node; - this.openCurrent(); - node = new XMLDTDEntity(this, false, name, value); - this.onData(this.writer.dtdEntity(node, this.currentLevel + 1)); - return this; - }; - - XMLDocumentCB.prototype.pEntity = function(name, value) { - var node; - this.openCurrent(); - node = new XMLDTDEntity(this, true, name, value); - this.onData(this.writer.dtdEntity(node, this.currentLevel + 1)); - return this; - }; - - XMLDocumentCB.prototype.notation = function(name, value) { - var node; - this.openCurrent(); - node = new XMLDTDNotation(this, name, value); - this.onData(this.writer.dtdNotation(node, this.currentLevel + 1)); - return this; - }; - - XMLDocumentCB.prototype.up = function() { - if (this.currentLevel < 0) { - throw new Error("The document node has no parent"); - } - if (this.currentNode) { - if (this.currentNode.children) { - this.closeNode(this.currentNode); - } else { - this.openNode(this.currentNode); - } - this.currentNode = null; - } else { - this.closeNode(this.openTags[this.currentLevel]); - } - delete this.openTags[this.currentLevel]; - this.currentLevel--; - return this; - }; - - XMLDocumentCB.prototype.end = function() { - while (this.currentLevel >= 0) { - this.up(); - } - return this.onEnd(); - }; - - XMLDocumentCB.prototype.openCurrent = function() { - if (this.currentNode) { - this.currentNode.children = true; - return this.openNode(this.currentNode); - } - }; - - XMLDocumentCB.prototype.openNode = function(node) { - if (!node.isOpen) { - if (!this.root && this.currentLevel === 0 && node instanceof XMLElement) { - this.root = node; - } - this.onData(this.writer.openNode(node, this.currentLevel)); - return node.isOpen = true; - } - }; - - XMLDocumentCB.prototype.closeNode = function(node) { - if (!node.isClosed) { - this.onData(this.writer.closeNode(node, this.currentLevel)); - return node.isClosed = true; - } - }; - - XMLDocumentCB.prototype.onData = function(chunk) { - this.documentStarted = true; - return this.onDataCallback(chunk); - }; - - XMLDocumentCB.prototype.onEnd = function() { - this.documentCompleted = true; - return this.onEndCallback(); - }; - - XMLDocumentCB.prototype.ele = function() { - return this.element.apply(this, arguments); - }; - - XMLDocumentCB.prototype.nod = function(name, attributes, text) { - return this.node(name, attributes, text); - }; - - XMLDocumentCB.prototype.txt = function(value) { - return this.text(value); - }; - - XMLDocumentCB.prototype.dat = function(value) { - return this.cdata(value); - }; - - XMLDocumentCB.prototype.com = function(value) { - return this.comment(value); - }; - - XMLDocumentCB.prototype.ins = function(target, value) { - return this.instruction(target, value); - }; - - XMLDocumentCB.prototype.dec = function(version, encoding, standalone) { - return this.declaration(version, encoding, standalone); - }; - - XMLDocumentCB.prototype.dtd = function(root, pubID, sysID) { - return this.doctype(root, pubID, sysID); - }; - - XMLDocumentCB.prototype.e = function(name, attributes, text) { - return this.element(name, attributes, text); - }; - - XMLDocumentCB.prototype.n = function(name, attributes, text) { - return this.node(name, attributes, text); - }; - - XMLDocumentCB.prototype.t = function(value) { - return this.text(value); - }; - - XMLDocumentCB.prototype.d = function(value) { - return this.cdata(value); - }; - - XMLDocumentCB.prototype.c = function(value) { - return this.comment(value); - }; - - XMLDocumentCB.prototype.r = function(value) { - return this.raw(value); - }; - - XMLDocumentCB.prototype.i = function(target, value) { - return this.instruction(target, value); - }; - - XMLDocumentCB.prototype.att = function() { - if (this.currentNode && this.currentNode instanceof XMLDocType) { - return this.attList.apply(this, arguments); - } else { - return this.attribute.apply(this, arguments); - } - }; - - XMLDocumentCB.prototype.a = function() { - if (this.currentNode && this.currentNode instanceof XMLDocType) { - return this.attList.apply(this, arguments); - } else { - return this.attribute.apply(this, arguments); - } - }; - - XMLDocumentCB.prototype.ent = function(name, value) { - return this.entity(name, value); - }; - - XMLDocumentCB.prototype.pent = function(name, value) { - return this.pEntity(name, value); - }; - - XMLDocumentCB.prototype.not = function(name, value) { - return this.notation(name, value); - }; - - return XMLDocumentCB; - - })(); - -}).call(this); diff --git a/node_modules/xmlbuilder/lib/XMLElement.js b/node_modules/xmlbuilder/lib/XMLElement.js index 620714b72..27504a872 100644 --- a/node_modules/xmlbuilder/lib/XMLElement.js +++ b/node_modules/xmlbuilder/lib/XMLElement.js @@ -1,15 +1,23 @@ -// Generated by CoffeeScript 1.10.0 +// Generated by CoffeeScript 1.9.1 (function() { - var XMLAttribute, XMLElement, XMLNode, isFunction, isObject, ref, + var XMLAttribute, XMLElement, XMLNode, XMLProcessingInstruction, create, every, isFunction, isObject, extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, hasProp = {}.hasOwnProperty; - ref = require('./Utility'), isObject = ref.isObject, isFunction = ref.isFunction; + create = require('lodash/create'); + + isObject = require('lodash/isObject'); + + isFunction = require('lodash/isFunction'); + + every = require('lodash/every'); XMLNode = require('./XMLNode'); XMLAttribute = require('./XMLAttribute'); + XMLProcessingInstruction = require('./XMLProcessingInstruction'); + module.exports = XMLElement = (function(superClass) { extend(XMLElement, superClass); @@ -19,30 +27,33 @@ throw new Error("Missing element name"); } this.name = this.stringify.eleName(name); + this.children = []; + this.instructions = []; this.attributes = {}; if (attributes != null) { this.attribute(attributes); } - if (parent.isDocument) { - this.isRoot = true; - this.documentObject = parent; - parent.rootObject = this; - } } XMLElement.prototype.clone = function() { - var att, attName, clonedSelf, ref1; - clonedSelf = Object.create(this); + var att, attName, clonedSelf, i, len, pi, ref, ref1; + clonedSelf = create(XMLElement.prototype, this); if (clonedSelf.isRoot) { clonedSelf.documentObject = null; } clonedSelf.attributes = {}; - ref1 = this.attributes; - for (attName in ref1) { - if (!hasProp.call(ref1, attName)) continue; - att = ref1[attName]; + ref = this.attributes; + for (attName in ref) { + if (!hasProp.call(ref, attName)) continue; + att = ref[attName]; clonedSelf.attributes[attName] = att.clone(); } + clonedSelf.instructions = []; + ref1 = this.instructions; + for (i = 0, len = ref1.length; i < len; i++) { + pi = ref1[i]; + clonedSelf.instructions.push(pi.clone()); + } clonedSelf.children = []; this.children.forEach(function(child) { var clonedChild; @@ -92,18 +103,108 @@ return this; }; - XMLElement.prototype.toString = function(options) { - return this.options.writer.set(options).element(this); + XMLElement.prototype.instruction = function(target, value) { + var i, insTarget, insValue, instruction, len; + if (target != null) { + target = target.valueOf(); + } + if (value != null) { + value = value.valueOf(); + } + if (Array.isArray(target)) { + for (i = 0, len = target.length; i < len; i++) { + insTarget = target[i]; + this.instruction(insTarget); + } + } else if (isObject(target)) { + for (insTarget in target) { + if (!hasProp.call(target, insTarget)) continue; + insValue = target[insTarget]; + this.instruction(insTarget, insValue); + } + } else { + if (isFunction(value)) { + value = value.apply(); + } + instruction = new XMLProcessingInstruction(this, target, value); + this.instructions.push(instruction); + } + return this; + }; + + XMLElement.prototype.toString = function(options, level) { + var att, child, i, indent, instruction, j, len, len1, name, newline, offset, pretty, r, ref, ref1, ref2, ref3, ref4, ref5, space; + pretty = (options != null ? options.pretty : void 0) || false; + indent = (ref = options != null ? options.indent : void 0) != null ? ref : ' '; + offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0; + newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n'; + level || (level = 0); + space = new Array(level + offset + 1).join(indent); + r = ''; + ref3 = this.instructions; + for (i = 0, len = ref3.length; i < len; i++) { + instruction = ref3[i]; + r += instruction.toString(options, level); + } + if (pretty) { + r += space; + } + r += '<' + this.name; + ref4 = this.attributes; + for (name in ref4) { + if (!hasProp.call(ref4, name)) continue; + att = ref4[name]; + r += att.toString(options); + } + if (this.children.length === 0 || every(this.children, function(e) { + return e.value === ''; + })) { + r += '/>'; + if (pretty) { + r += newline; + } + } else if (pretty && this.children.length === 1 && (this.children[0].value != null)) { + r += '>'; + r += this.children[0].value; + r += '</' + this.name + '>'; + r += newline; + } else { + r += '>'; + if (pretty) { + r += newline; + } + ref5 = this.children; + for (j = 0, len1 = ref5.length; j < len1; j++) { + child = ref5[j]; + r += child.toString(options, level + 1); + } + if (pretty) { + r += space; + } + r += '</' + this.name + '>'; + if (pretty) { + r += newline; + } + } + return r; }; XMLElement.prototype.att = function(name, value) { return this.attribute(name, value); }; + XMLElement.prototype.ins = function(target, value) { + return this.instruction(target, value); + }; + XMLElement.prototype.a = function(name, value) { return this.attribute(name, value); }; + XMLElement.prototype.i = function(target, value) { + return this.instruction(target, value); + }; + return XMLElement; })(XMLNode); diff --git a/node_modules/xmlbuilder/lib/XMLNode.js b/node_modules/xmlbuilder/lib/XMLNode.js index 1b3b456ab..0a6340b44 100644 --- a/node_modules/xmlbuilder/lib/XMLNode.js +++ b/node_modules/xmlbuilder/lib/XMLNode.js @@ -1,9 +1,13 @@ -// Generated by CoffeeScript 1.10.0 +// Generated by CoffeeScript 1.9.1 (function() { - var XMLCData, XMLComment, XMLDeclaration, XMLDocType, XMLElement, XMLNode, XMLProcessingInstruction, XMLRaw, XMLText, isEmpty, isFunction, isObject, ref, + var XMLCData, XMLComment, XMLDeclaration, XMLDocType, XMLElement, XMLNode, XMLRaw, XMLText, isEmpty, isFunction, isObject, hasProp = {}.hasOwnProperty; - ref = require('./Utility'), isObject = ref.isObject, isFunction = ref.isFunction, isEmpty = ref.isEmpty; + isObject = require('lodash/isObject'); + + isFunction = require('lodash/isFunction'); + + isEmpty = require('lodash/isEmpty'); XMLElement = null; @@ -19,17 +23,12 @@ XMLText = null; - XMLProcessingInstruction = null; - module.exports = XMLNode = (function() { function XMLNode(parent) { this.parent = parent; - if (this.parent) { - this.options = this.parent.options; - this.stringify = this.parent.stringify; - } - this.children = []; - if (!XMLElement) { + this.options = this.parent.options; + this.stringify = this.parent.stringify; + if (XMLElement === null) { XMLElement = require('./XMLElement'); XMLCData = require('./XMLCData'); XMLComment = require('./XMLComment'); @@ -37,19 +36,18 @@ XMLDocType = require('./XMLDocType'); XMLRaw = require('./XMLRaw'); XMLText = require('./XMLText'); - XMLProcessingInstruction = require('./XMLProcessingInstruction'); } } XMLNode.prototype.element = function(name, attributes, text) { - var childNode, item, j, k, key, lastChild, len, len1, ref1, val; + var childNode, item, j, k, key, lastChild, len, len1, ref, val; lastChild = null; if (attributes == null) { attributes = {}; } attributes = attributes.valueOf(); if (!isObject(attributes)) { - ref1 = [attributes, text], text = ref1[0], attributes = ref1[1]; + ref = [attributes, text], text = ref[0], attributes = ref[1]; } if (name != null) { name = name.valueOf(); @@ -73,6 +71,8 @@ } if (!this.options.ignoreDecorators && this.stringify.convertAttKey && key.indexOf(this.stringify.convertAttKey) === 0) { lastChild = this.attribute(key.substr(this.stringify.convertAttKey.length), val); + } else if (!this.options.ignoreDecorators && this.stringify.convertPIKey && key.indexOf(this.stringify.convertPIKey) === 0) { + lastChild = this.instruction(key.substr(this.stringify.convertPIKey.length), val); } else if (!this.options.separateArrayItems && Array.isArray(val)) { for (k = 0, len1 = val.length; k < len1; k++) { item = val[k]; @@ -96,8 +96,6 @@ lastChild = this.comment(text); } else if (!this.options.ignoreDecorators && this.stringify.convertRawKey && name.indexOf(this.stringify.convertRawKey) === 0) { lastChild = this.raw(text); - } else if (!this.options.ignoreDecorators && this.stringify.convertPIKey && name.indexOf(this.stringify.convertPIKey) === 0) { - lastChild = this.instruction(name.substr(this.stringify.convertPIKey.length), text); } else { lastChild = this.node(name, attributes, text); } @@ -133,24 +131,26 @@ }; XMLNode.prototype.remove = function() { - var i, ref1; + var i, ref; if (this.isRoot) { throw new Error("Cannot remove the root element"); } i = this.parent.children.indexOf(this); - [].splice.apply(this.parent.children, [i, i - i + 1].concat(ref1 = [])), ref1; + [].splice.apply(this.parent.children, [i, i - i + 1].concat(ref = [])), ref; return this.parent; }; XMLNode.prototype.node = function(name, attributes, text) { - var child, ref1; + var child, ref; if (name != null) { name = name.valueOf(); } - attributes || (attributes = {}); + if (attributes == null) { + attributes = {}; + } attributes = attributes.valueOf(); if (!isObject(attributes)) { - ref1 = [attributes, text], text = ref1[0], attributes = ref1[1]; + ref = [attributes, text], text = ref[0], attributes = ref[1]; } child = new XMLElement(this, name, attributes); if (text != null) { @@ -181,24 +181,6 @@ return this; }; - XMLNode.prototype.commentBefore = function(value) { - var child, i, removed; - i = this.parent.children.indexOf(this); - removed = this.parent.children.splice(i); - child = this.parent.comment(value); - Array.prototype.push.apply(this.parent.children, removed); - return this; - }; - - XMLNode.prototype.commentAfter = function(value) { - var child, i, removed; - i = this.parent.children.indexOf(this); - removed = this.parent.children.splice(i + 1); - child = this.parent.comment(value); - Array.prototype.push.apply(this.parent.children, removed); - return this; - }; - XMLNode.prototype.raw = function(value) { var child; child = new XMLRaw(this, value); @@ -206,86 +188,19 @@ return this; }; - XMLNode.prototype.instruction = function(target, value) { - var insTarget, insValue, instruction, j, len; - if (target != null) { - target = target.valueOf(); - } - if (value != null) { - value = value.valueOf(); - } - if (Array.isArray(target)) { - for (j = 0, len = target.length; j < len; j++) { - insTarget = target[j]; - this.instruction(insTarget); - } - } else if (isObject(target)) { - for (insTarget in target) { - if (!hasProp.call(target, insTarget)) continue; - insValue = target[insTarget]; - this.instruction(insTarget, insValue); - } - } else { - if (isFunction(value)) { - value = value.apply(); - } - instruction = new XMLProcessingInstruction(this, target, value); - this.children.push(instruction); - } - return this; - }; - - XMLNode.prototype.instructionBefore = function(target, value) { - var child, i, removed; - i = this.parent.children.indexOf(this); - removed = this.parent.children.splice(i); - child = this.parent.instruction(target, value); - Array.prototype.push.apply(this.parent.children, removed); - return this; - }; - - XMLNode.prototype.instructionAfter = function(target, value) { - var child, i, removed; - i = this.parent.children.indexOf(this); - removed = this.parent.children.splice(i + 1); - child = this.parent.instruction(target, value); - Array.prototype.push.apply(this.parent.children, removed); - return this; - }; - XMLNode.prototype.declaration = function(version, encoding, standalone) { var doc, xmldec; doc = this.document(); xmldec = new XMLDeclaration(doc, version, encoding, standalone); - if (doc.children[0] instanceof XMLDeclaration) { - doc.children[0] = xmldec; - } else { - doc.children.unshift(xmldec); - } - return doc.root() || doc; + doc.xmldec = xmldec; + return doc.root(); }; XMLNode.prototype.doctype = function(pubID, sysID) { - var child, doc, doctype, i, j, k, len, len1, ref1, ref2; + var doc, doctype; doc = this.document(); doctype = new XMLDocType(doc, pubID, sysID); - ref1 = doc.children; - for (i = j = 0, len = ref1.length; j < len; i = ++j) { - child = ref1[i]; - if (child instanceof XMLDocType) { - doc.children[i] = doctype; - return doctype; - } - } - ref2 = doc.children; - for (i = k = 0, len1 = ref2.length; k < len1; i = ++k) { - child = ref2[i]; - if (child.isRoot) { - doc.children.splice(i, 0, doctype); - return doctype; - } - } - doc.children.push(doctype); + doc.doctype = doctype; return doctype; }; @@ -297,37 +212,30 @@ }; XMLNode.prototype.root = function() { - var node; - node = this; - while (node) { - if (node.isDocument) { - return node.rootObject; - } else if (node.isRoot) { - return node; - } else { - node = node.parent; - } + var child; + if (this.isRoot) { + return this; + } + child = this.parent; + while (!child.isRoot) { + child = child.parent; } + return child; }; XMLNode.prototype.document = function() { - var node; - node = this; - while (node) { - if (node.isDocument) { - return node; - } else { - node = node.parent; - } - } + return this.root().documentObject; }; XMLNode.prototype.end = function(options) { - return this.document().end(options); + return this.document().toString(options); }; XMLNode.prototype.prev = function() { var i; + if (this.isRoot) { + throw new Error("Root node has no siblings"); + } i = this.parent.children.indexOf(this); if (i < 1) { throw new Error("Already at the first node"); @@ -337,6 +245,9 @@ XMLNode.prototype.next = function() { var i; + if (this.isRoot) { + throw new Error("Root node has no siblings"); + } i = this.parent.children.indexOf(this); if (i === -1 || i === this.parent.children.length - 1) { throw new Error("Already at the last node"); @@ -344,9 +255,9 @@ return this.parent.children[i + 1]; }; - XMLNode.prototype.importDocument = function(doc) { + XMLNode.prototype.importXMLBuilder = function(xmlbuilder) { var clonedRoot; - clonedRoot = doc.root().clone(); + clonedRoot = xmlbuilder.root().clone(); clonedRoot.parent = this; clonedRoot.isRoot = false; this.children.push(clonedRoot); @@ -373,10 +284,6 @@ return this.comment(value); }; - XMLNode.prototype.ins = function(target, value) { - return this.instruction(target, value); - }; - XMLNode.prototype.doc = function() { return this.document(); }; @@ -413,18 +320,10 @@ return this.raw(value); }; - XMLNode.prototype.i = function(target, value) { - return this.instruction(target, value); - }; - XMLNode.prototype.u = function() { return this.up(); }; - XMLNode.prototype.importXMLBuilder = function(doc) { - return this.importDocument(doc); - }; - return XMLNode; })(); diff --git a/node_modules/xmlbuilder/lib/XMLProcessingInstruction.js b/node_modules/xmlbuilder/lib/XMLProcessingInstruction.js index a15be34d2..596f5a6de 100644 --- a/node_modules/xmlbuilder/lib/XMLProcessingInstruction.js +++ b/node_modules/xmlbuilder/lib/XMLProcessingInstruction.js @@ -1,16 +1,12 @@ -// Generated by CoffeeScript 1.10.0 +// Generated by CoffeeScript 1.9.1 (function() { - var XMLNode, XMLProcessingInstruction, - extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, - hasProp = {}.hasOwnProperty; + var XMLProcessingInstruction, create; - XMLNode = require('./XMLNode'); - - module.exports = XMLProcessingInstruction = (function(superClass) { - extend(XMLProcessingInstruction, superClass); + create = require('lodash/create'); + module.exports = XMLProcessingInstruction = (function() { function XMLProcessingInstruction(parent, target, value) { - XMLProcessingInstruction.__super__.constructor.call(this, parent); + this.stringify = parent.stringify; if (target == null) { throw new Error("Missing instruction target"); } @@ -21,15 +17,35 @@ } XMLProcessingInstruction.prototype.clone = function() { - return Object.create(this); + return create(XMLProcessingInstruction.prototype, this); }; - XMLProcessingInstruction.prototype.toString = function(options) { - return this.options.writer.set(options).processingInstruction(this); + XMLProcessingInstruction.prototype.toString = function(options, level) { + var indent, newline, offset, pretty, r, ref, ref1, ref2, space; + pretty = (options != null ? options.pretty : void 0) || false; + indent = (ref = options != null ? options.indent : void 0) != null ? ref : ' '; + offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0; + newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n'; + level || (level = 0); + space = new Array(level + offset + 1).join(indent); + r = ''; + if (pretty) { + r += space; + } + r += '<?'; + r += this.target; + if (this.value) { + r += ' ' + this.value; + } + r += '?>'; + if (pretty) { + r += newline; + } + return r; }; return XMLProcessingInstruction; - })(XMLNode); + })(); }).call(this); diff --git a/node_modules/xmlbuilder/lib/XMLRaw.js b/node_modules/xmlbuilder/lib/XMLRaw.js index 152f83b8e..9f4896231 100644 --- a/node_modules/xmlbuilder/lib/XMLRaw.js +++ b/node_modules/xmlbuilder/lib/XMLRaw.js @@ -1,9 +1,11 @@ -// Generated by CoffeeScript 1.10.0 +// Generated by CoffeeScript 1.9.1 (function() { - var XMLNode, XMLRaw, + var XMLNode, XMLRaw, create, extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, hasProp = {}.hasOwnProperty; + create = require('lodash/create'); + XMLNode = require('./XMLNode'); module.exports = XMLRaw = (function(superClass) { @@ -18,11 +20,26 @@ } XMLRaw.prototype.clone = function() { - return Object.create(this); + return create(XMLRaw.prototype, this); }; - XMLRaw.prototype.toString = function(options) { - return this.options.writer.set(options).raw(this); + XMLRaw.prototype.toString = function(options, level) { + var indent, newline, offset, pretty, r, ref, ref1, ref2, space; + pretty = (options != null ? options.pretty : void 0) || false; + indent = (ref = options != null ? options.indent : void 0) != null ? ref : ' '; + offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0; + newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n'; + level || (level = 0); + space = new Array(level + offset + 1).join(indent); + r = ''; + if (pretty) { + r += space; + } + r += this.value; + if (pretty) { + r += newline; + } + return r; }; return XMLRaw; diff --git a/node_modules/xmlbuilder/lib/XMLStreamWriter.js b/node_modules/xmlbuilder/lib/XMLStreamWriter.js deleted file mode 100644 index 10a092613..000000000 --- a/node_modules/xmlbuilder/lib/XMLStreamWriter.js +++ /dev/null @@ -1,278 +0,0 @@ -// Generated by CoffeeScript 1.10.0 -(function() { - var XMLCData, XMLComment, XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDeclaration, XMLDocType, XMLElement, XMLProcessingInstruction, XMLRaw, XMLStreamWriter, XMLText, XMLWriterBase, - extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, - hasProp = {}.hasOwnProperty; - - XMLDeclaration = require('./XMLDeclaration'); - - XMLDocType = require('./XMLDocType'); - - XMLCData = require('./XMLCData'); - - XMLComment = require('./XMLComment'); - - XMLElement = require('./XMLElement'); - - XMLRaw = require('./XMLRaw'); - - XMLText = require('./XMLText'); - - XMLProcessingInstruction = require('./XMLProcessingInstruction'); - - XMLDTDAttList = require('./XMLDTDAttList'); - - XMLDTDElement = require('./XMLDTDElement'); - - XMLDTDEntity = require('./XMLDTDEntity'); - - XMLDTDNotation = require('./XMLDTDNotation'); - - XMLWriterBase = require('./XMLWriterBase'); - - module.exports = XMLStreamWriter = (function(superClass) { - extend(XMLStreamWriter, superClass); - - function XMLStreamWriter(stream, options) { - this.stream = stream; - XMLStreamWriter.__super__.constructor.call(this, options); - } - - XMLStreamWriter.prototype.document = function(doc) { - var child, i, j, len, len1, ref, ref1, results; - ref = doc.children; - for (i = 0, len = ref.length; i < len; i++) { - child = ref[i]; - child.isLastRootNode = false; - } - doc.children[doc.children.length - 1].isLastRootNode = true; - ref1 = doc.children; - results = []; - for (j = 0, len1 = ref1.length; j < len1; j++) { - child = ref1[j]; - switch (false) { - case !(child instanceof XMLDeclaration): - results.push(this.declaration(child)); - break; - case !(child instanceof XMLDocType): - results.push(this.docType(child)); - break; - case !(child instanceof XMLComment): - results.push(this.comment(child)); - break; - case !(child instanceof XMLProcessingInstruction): - results.push(this.processingInstruction(child)); - break; - default: - results.push(this.element(child)); - } - } - return results; - }; - - XMLStreamWriter.prototype.attribute = function(att) { - return this.stream.write(' ' + att.name + '="' + att.value + '"'); - }; - - XMLStreamWriter.prototype.cdata = function(node, level) { - return this.stream.write(this.space(level) + '<![CDATA[' + node.text + ']]>' + this.endline(node)); - }; - - XMLStreamWriter.prototype.comment = function(node, level) { - return this.stream.write(this.space(level) + '<!-- ' + node.text + ' -->' + this.endline(node)); - }; - - XMLStreamWriter.prototype.declaration = function(node, level) { - this.stream.write(this.space(level)); - this.stream.write('<?xml version="' + node.version + '"'); - if (node.encoding != null) { - this.stream.write(' encoding="' + node.encoding + '"'); - } - if (node.standalone != null) { - this.stream.write(' standalone="' + node.standalone + '"'); - } - this.stream.write('?>'); - return this.stream.write(this.endline(node)); - }; - - XMLStreamWriter.prototype.docType = function(node, level) { - var child, i, len, ref; - level || (level = 0); - this.stream.write(this.space(level)); - this.stream.write('<!DOCTYPE ' + node.root().name); - if (node.pubID && node.sysID) { - this.stream.write(' PUBLIC "' + node.pubID + '" "' + node.sysID + '"'); - } else if (node.sysID) { - this.stream.write(' SYSTEM "' + node.sysID + '"'); - } - if (node.children.length > 0) { - this.stream.write(' ['); - this.stream.write(this.endline(node)); - ref = node.children; - for (i = 0, len = ref.length; i < len; i++) { - child = ref[i]; - switch (false) { - case !(child instanceof XMLDTDAttList): - this.dtdAttList(child, level + 1); - break; - case !(child instanceof XMLDTDElement): - this.dtdElement(child, level + 1); - break; - case !(child instanceof XMLDTDEntity): - this.dtdEntity(child, level + 1); - break; - case !(child instanceof XMLDTDNotation): - this.dtdNotation(child, level + 1); - break; - case !(child instanceof XMLCData): - this.cdata(child, level + 1); - break; - case !(child instanceof XMLComment): - this.comment(child, level + 1); - break; - case !(child instanceof XMLProcessingInstruction): - this.processingInstruction(child, level + 1); - break; - default: - throw new Error("Unknown DTD node type: " + child.constructor.name); - } - } - this.stream.write(']'); - } - this.stream.write('>'); - return this.stream.write(this.endline(node)); - }; - - XMLStreamWriter.prototype.element = function(node, level) { - var att, child, i, len, name, ref, ref1, space; - level || (level = 0); - space = this.space(level); - this.stream.write(space + '<' + node.name); - ref = node.attributes; - for (name in ref) { - if (!hasProp.call(ref, name)) continue; - att = ref[name]; - this.attribute(att); - } - if (node.children.length === 0 || node.children.every(function(e) { - return e.value === ''; - })) { - if (this.allowEmpty) { - this.stream.write('></' + node.name + '>'); - } else { - this.stream.write('/>'); - } - } else if (this.pretty && node.children.length === 1 && (node.children[0].value != null)) { - this.stream.write('>'); - this.stream.write(node.children[0].value); - this.stream.write('</' + node.name + '>'); - } else { - this.stream.write('>' + this.newline); - ref1 = node.children; - for (i = 0, len = ref1.length; i < len; i++) { - child = ref1[i]; - switch (false) { - case !(child instanceof XMLCData): - this.cdata(child, level + 1); - break; - case !(child instanceof XMLComment): - this.comment(child, level + 1); - break; - case !(child instanceof XMLElement): - this.element(child, level + 1); - break; - case !(child instanceof XMLRaw): - this.raw(child, level + 1); - break; - case !(child instanceof XMLText): - this.text(child, level + 1); - break; - case !(child instanceof XMLProcessingInstruction): - this.processingInstruction(child, level + 1); - break; - default: - throw new Error("Unknown XML node type: " + child.constructor.name); - } - } - this.stream.write(space + '</' + node.name + '>'); - } - return this.stream.write(this.endline(node)); - }; - - XMLStreamWriter.prototype.processingInstruction = function(node, level) { - this.stream.write(this.space(level) + '<?' + node.target); - if (node.value) { - this.stream.write(' ' + node.value); - } - return this.stream.write('?>' + this.endline(node)); - }; - - XMLStreamWriter.prototype.raw = function(node, level) { - return this.stream.write(this.space(level) + node.value + this.endline(node)); - }; - - XMLStreamWriter.prototype.text = function(node, level) { - return this.stream.write(this.space(level) + node.value + this.endline(node)); - }; - - XMLStreamWriter.prototype.dtdAttList = function(node, level) { - this.stream.write(this.space(level) + '<!ATTLIST ' + node.elementName + ' ' + node.attributeName + ' ' + node.attributeType); - if (node.defaultValueType !== '#DEFAULT') { - this.stream.write(' ' + node.defaultValueType); - } - if (node.defaultValue) { - this.stream.write(' "' + node.defaultValue + '"'); - } - return this.stream.write('>' + this.endline(node)); - }; - - XMLStreamWriter.prototype.dtdElement = function(node, level) { - return this.stream.write(this.space(level) + '<!ELEMENT ' + node.name + ' ' + node.value + '>' + this.endline(node)); - }; - - XMLStreamWriter.prototype.dtdEntity = function(node, level) { - this.stream.write(this.space(level) + '<!ENTITY'); - if (node.pe) { - this.stream.write(' %'); - } - this.stream.write(' ' + node.name); - if (node.value) { - this.stream.write(' "' + node.value + '"'); - } else { - if (node.pubID && node.sysID) { - this.stream.write(' PUBLIC "' + node.pubID + '" "' + node.sysID + '"'); - } else if (node.sysID) { - this.stream.write(' SYSTEM "' + node.sysID + '"'); - } - if (node.nData) { - this.stream.write(' NDATA ' + node.nData); - } - } - return this.stream.write('>' + this.endline(node)); - }; - - XMLStreamWriter.prototype.dtdNotation = function(node, level) { - this.stream.write(this.space(level) + '<!NOTATION ' + node.name); - if (node.pubID && node.sysID) { - this.stream.write(' PUBLIC "' + node.pubID + '" "' + node.sysID + '"'); - } else if (node.pubID) { - this.stream.write(' PUBLIC "' + node.pubID + '"'); - } else if (node.sysID) { - this.stream.write(' SYSTEM "' + node.sysID + '"'); - } - return this.stream.write('>' + this.endline(node)); - }; - - XMLStreamWriter.prototype.endline = function(node) { - if (!node.isLastRootNode) { - return this.newline; - } else { - return ''; - } - }; - - return XMLStreamWriter; - - })(XMLWriterBase); - -}).call(this); diff --git a/node_modules/xmlbuilder/lib/XMLStringWriter.js b/node_modules/xmlbuilder/lib/XMLStringWriter.js deleted file mode 100644 index 3164006e9..000000000 --- a/node_modules/xmlbuilder/lib/XMLStringWriter.js +++ /dev/null @@ -1,302 +0,0 @@ -// Generated by CoffeeScript 1.10.0 -(function() { - var XMLCData, XMLComment, XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDeclaration, XMLDocType, XMLElement, XMLProcessingInstruction, XMLRaw, XMLStringWriter, XMLText, XMLWriterBase, - extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, - hasProp = {}.hasOwnProperty; - - XMLDeclaration = require('./XMLDeclaration'); - - XMLDocType = require('./XMLDocType'); - - XMLCData = require('./XMLCData'); - - XMLComment = require('./XMLComment'); - - XMLElement = require('./XMLElement'); - - XMLRaw = require('./XMLRaw'); - - XMLText = require('./XMLText'); - - XMLProcessingInstruction = require('./XMLProcessingInstruction'); - - XMLDTDAttList = require('./XMLDTDAttList'); - - XMLDTDElement = require('./XMLDTDElement'); - - XMLDTDEntity = require('./XMLDTDEntity'); - - XMLDTDNotation = require('./XMLDTDNotation'); - - XMLWriterBase = require('./XMLWriterBase'); - - module.exports = XMLStringWriter = (function(superClass) { - extend(XMLStringWriter, superClass); - - function XMLStringWriter(options) { - XMLStringWriter.__super__.constructor.call(this, options); - } - - XMLStringWriter.prototype.document = function(doc) { - var child, i, len, r, ref; - r = ''; - ref = doc.children; - for (i = 0, len = ref.length; i < len; i++) { - child = ref[i]; - r += (function() { - switch (false) { - case !(child instanceof XMLDeclaration): - return this.declaration(child); - case !(child instanceof XMLDocType): - return this.docType(child); - case !(child instanceof XMLComment): - return this.comment(child); - case !(child instanceof XMLProcessingInstruction): - return this.processingInstruction(child); - default: - return this.element(child, 0); - } - }).call(this); - } - if (this.pretty && r.slice(-this.newline.length) === this.newline) { - r = r.slice(0, -this.newline.length); - } - return r; - }; - - XMLStringWriter.prototype.attribute = function(att) { - return ' ' + att.name + '="' + att.value + '"'; - }; - - XMLStringWriter.prototype.cdata = function(node, level) { - return this.space(level) + '<![CDATA[' + node.text + ']]>' + this.newline; - }; - - XMLStringWriter.prototype.comment = function(node, level) { - return this.space(level) + '<!-- ' + node.text + ' -->' + this.newline; - }; - - XMLStringWriter.prototype.declaration = function(node, level) { - var r; - r = this.space(level); - r += '<?xml version="' + node.version + '"'; - if (node.encoding != null) { - r += ' encoding="' + node.encoding + '"'; - } - if (node.standalone != null) { - r += ' standalone="' + node.standalone + '"'; - } - r += '?>'; - r += this.newline; - return r; - }; - - XMLStringWriter.prototype.docType = function(node, level) { - var child, i, len, r, ref; - level || (level = 0); - r = this.space(level); - r += '<!DOCTYPE ' + node.root().name; - if (node.pubID && node.sysID) { - r += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"'; - } else if (node.sysID) { - r += ' SYSTEM "' + node.sysID + '"'; - } - if (node.children.length > 0) { - r += ' ['; - r += this.newline; - ref = node.children; - for (i = 0, len = ref.length; i < len; i++) { - child = ref[i]; - r += (function() { - switch (false) { - case !(child instanceof XMLDTDAttList): - return this.dtdAttList(child, level + 1); - case !(child instanceof XMLDTDElement): - return this.dtdElement(child, level + 1); - case !(child instanceof XMLDTDEntity): - return this.dtdEntity(child, level + 1); - case !(child instanceof XMLDTDNotation): - return this.dtdNotation(child, level + 1); - case !(child instanceof XMLCData): - return this.cdata(child, level + 1); - case !(child instanceof XMLComment): - return this.comment(child, level + 1); - case !(child instanceof XMLProcessingInstruction): - return this.processingInstruction(child, level + 1); - default: - throw new Error("Unknown DTD node type: " + child.constructor.name); - } - }).call(this); - } - r += ']'; - } - r += '>'; - r += this.newline; - return r; - }; - - XMLStringWriter.prototype.element = function(node, level) { - var att, child, i, len, name, r, ref, ref1, space; - level || (level = 0); - space = this.space(level); - r = ''; - r += space + '<' + node.name; - ref = node.attributes; - for (name in ref) { - if (!hasProp.call(ref, name)) continue; - att = ref[name]; - r += this.attribute(att); - } - if (node.children.length === 0 || node.children.every(function(e) { - return e.value === ''; - })) { - if (this.allowEmpty) { - r += '></' + node.name + '>' + this.newline; - } else { - r += '/>' + this.newline; - } - } else if (this.pretty && node.children.length === 1 && (node.children[0].value != null)) { - r += '>'; - r += node.children[0].value; - r += '</' + node.name + '>' + this.newline; - } else { - r += '>' + this.newline; - ref1 = node.children; - for (i = 0, len = ref1.length; i < len; i++) { - child = ref1[i]; - r += (function() { - switch (false) { - case !(child instanceof XMLCData): - return this.cdata(child, level + 1); - case !(child instanceof XMLComment): - return this.comment(child, level + 1); - case !(child instanceof XMLElement): - return this.element(child, level + 1); - case !(child instanceof XMLRaw): - return this.raw(child, level + 1); - case !(child instanceof XMLText): - return this.text(child, level + 1); - case !(child instanceof XMLProcessingInstruction): - return this.processingInstruction(child, level + 1); - default: - throw new Error("Unknown XML node type: " + child.constructor.name); - } - }).call(this); - } - r += space + '</' + node.name + '>' + this.newline; - } - return r; - }; - - XMLStringWriter.prototype.processingInstruction = function(node, level) { - var r; - r = this.space(level) + '<?' + node.target; - if (node.value) { - r += ' ' + node.value; - } - r += '?>' + this.newline; - return r; - }; - - XMLStringWriter.prototype.raw = function(node, level) { - return this.space(level) + node.value + this.newline; - }; - - XMLStringWriter.prototype.text = function(node, level) { - return this.space(level) + node.value + this.newline; - }; - - XMLStringWriter.prototype.dtdAttList = function(node, level) { - var r; - r = this.space(level) + '<!ATTLIST ' + node.elementName + ' ' + node.attributeName + ' ' + node.attributeType; - if (node.defaultValueType !== '#DEFAULT') { - r += ' ' + node.defaultValueType; - } - if (node.defaultValue) { - r += ' "' + node.defaultValue + '"'; - } - r += '>' + this.newline; - return r; - }; - - XMLStringWriter.prototype.dtdElement = function(node, level) { - return this.space(level) + '<!ELEMENT ' + node.name + ' ' + node.value + '>' + this.newline; - }; - - XMLStringWriter.prototype.dtdEntity = function(node, level) { - var r; - r = this.space(level) + '<!ENTITY'; - if (node.pe) { - r += ' %'; - } - r += ' ' + node.name; - if (node.value) { - r += ' "' + node.value + '"'; - } else { - if (node.pubID && node.sysID) { - r += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"'; - } else if (node.sysID) { - r += ' SYSTEM "' + node.sysID + '"'; - } - if (node.nData) { - r += ' NDATA ' + node.nData; - } - } - r += '>' + this.newline; - return r; - }; - - XMLStringWriter.prototype.dtdNotation = function(node, level) { - var r; - r = this.space(level) + '<!NOTATION ' + node.name; - if (node.pubID && node.sysID) { - r += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"'; - } else if (node.pubID) { - r += ' PUBLIC "' + node.pubID + '"'; - } else if (node.sysID) { - r += ' SYSTEM "' + node.sysID + '"'; - } - r += '>' + this.newline; - return r; - }; - - XMLStringWriter.prototype.openNode = function(node, level) { - var att, name, r, ref; - level || (level = 0); - if (node instanceof XMLElement) { - r = this.space(level) + '<' + node.name; - ref = node.attributes; - for (name in ref) { - if (!hasProp.call(ref, name)) continue; - att = ref[name]; - r += this.attribute(att); - } - r += (node.children ? '>' : '/>') + this.newline; - return r; - } else { - r = this.space(level) + '<!DOCTYPE ' + node.rootNodeName; - if (node.pubID && node.sysID) { - r += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"'; - } else if (node.sysID) { - r += ' SYSTEM "' + node.sysID + '"'; - } - r += (node.children ? ' [' : '>') + this.newline; - return r; - } - }; - - XMLStringWriter.prototype.closeNode = function(node, level) { - level || (level = 0); - switch (false) { - case !(node instanceof XMLElement): - return this.space(level) + '</' + node.name + '>' + this.newline; - case !(node instanceof XMLDocType): - return this.space(level) + ']>' + this.newline; - } - }; - - return XMLStringWriter; - - })(XMLWriterBase); - -}).call(this); diff --git a/node_modules/xmlbuilder/lib/XMLStringifier.js b/node_modules/xmlbuilder/lib/XMLStringifier.js index f54946131..c3c4722be 100644 --- a/node_modules/xmlbuilder/lib/XMLStringifier.js +++ b/node_modules/xmlbuilder/lib/XMLStringifier.js @@ -1,30 +1,25 @@ -// Generated by CoffeeScript 1.10.0 +// Generated by CoffeeScript 1.9.1 (function() { - var XMLStringifier, camelCase, kebabCase, ref, snakeCase, titleCase, + var XMLStringifier, bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, hasProp = {}.hasOwnProperty; - ref = require('./Utility'), camelCase = ref.camelCase, titleCase = ref.titleCase, kebabCase = ref.kebabCase, snakeCase = ref.snakeCase; - module.exports = XMLStringifier = (function() { function XMLStringifier(options) { this.assertLegalChar = bind(this.assertLegalChar, this); - var key, ref1, value; - options || (options = {}); - this.allowSurrogateChars = options.allowSurrogateChars; - this.noDoubleEncoding = options.noDoubleEncoding; - this.textCase = options.textCase; - ref1 = options.stringify || {}; - for (key in ref1) { - if (!hasProp.call(ref1, key)) continue; - value = ref1[key]; + var key, ref, value; + this.allowSurrogateChars = options != null ? options.allowSurrogateChars : void 0; + this.noDoubleEncoding = options != null ? options.noDoubleEncoding : void 0; + ref = (options != null ? options.stringify : void 0) || {}; + for (key in ref) { + if (!hasProp.call(ref, key)) continue; + value = ref[key]; this[key] = value; } } XMLStringifier.prototype.eleName = function(val) { val = '' + val || ''; - val = this.applyCase(val); return this.assertLegalChar(val); }; @@ -35,7 +30,9 @@ XMLStringifier.prototype.cdata = function(val) { val = '' + val || ''; - val = val.replace(']]>', ']]]]><![CDATA[>'); + if (val.match(/]]>/)) { + throw new Error("Invalid CDATA text: " + val); + } return this.assertLegalChar(val); }; @@ -52,8 +49,7 @@ }; XMLStringifier.prototype.attName = function(val) { - val = '' + val || ''; - return val = this.applyCase(val); + return '' + val || ''; }; XMLStringifier.prototype.attValue = function(val) { @@ -155,24 +151,6 @@ return str; }; - XMLStringifier.prototype.applyCase = function(str) { - switch (this.textCase) { - case "camel": - return camelCase(str); - case "title": - return titleCase(str); - case "kebab": - case "lower": - return kebabCase(str); - case "snake": - return snakeCase(str); - case "upper": - return kebabCase(str).toUpperCase(); - default: - return str; - } - }; - XMLStringifier.prototype.elEscape = function(str) { var ampregex; ampregex = this.noDoubleEncoding ? /(?!&\S+;)&/g : /&/g; @@ -182,7 +160,7 @@ XMLStringifier.prototype.attEscape = function(str) { var ampregex; ampregex = this.noDoubleEncoding ? /(?!&\S+;)&/g : /&/g; - return str.replace(ampregex, '&').replace(/</g, '<').replace(/"/g, '"').replace(/\t/g, '	').replace(/\n/g, '
').replace(/\r/g, '
'); + return str.replace(ampregex, '&').replace(/</g, '<').replace(/"/g, '"'); }; return XMLStringifier; diff --git a/node_modules/xmlbuilder/lib/XMLText.js b/node_modules/xmlbuilder/lib/XMLText.js index 8241581ed..c4f27ab49 100644 --- a/node_modules/xmlbuilder/lib/XMLText.js +++ b/node_modules/xmlbuilder/lib/XMLText.js @@ -1,9 +1,11 @@ -// Generated by CoffeeScript 1.10.0 +// Generated by CoffeeScript 1.9.1 (function() { - var XMLNode, XMLText, + var XMLNode, XMLText, create, extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, hasProp = {}.hasOwnProperty; + create = require('lodash/create'); + XMLNode = require('./XMLNode'); module.exports = XMLText = (function(superClass) { @@ -18,11 +20,26 @@ } XMLText.prototype.clone = function() { - return Object.create(this); + return create(XMLText.prototype, this); }; - XMLText.prototype.toString = function(options) { - return this.options.writer.set(options).text(this); + XMLText.prototype.toString = function(options, level) { + var indent, newline, offset, pretty, r, ref, ref1, ref2, space; + pretty = (options != null ? options.pretty : void 0) || false; + indent = (ref = options != null ? options.indent : void 0) != null ? ref : ' '; + offset = (ref1 = options != null ? options.offset : void 0) != null ? ref1 : 0; + newline = (ref2 = options != null ? options.newline : void 0) != null ? ref2 : '\n'; + level || (level = 0); + space = new Array(level + offset + 1).join(indent); + r = ''; + if (pretty) { + r += space; + } + r += this.value; + if (pretty) { + r += newline; + } + return r; }; return XMLText; diff --git a/node_modules/xmlbuilder/lib/XMLWriterBase.js b/node_modules/xmlbuilder/lib/XMLWriterBase.js deleted file mode 100644 index 0b28662e4..000000000 --- a/node_modules/xmlbuilder/lib/XMLWriterBase.js +++ /dev/null @@ -1,68 +0,0 @@ -// Generated by CoffeeScript 1.10.0 -(function() { - var XMLWriterBase, - hasProp = {}.hasOwnProperty; - - module.exports = XMLWriterBase = (function() { - function XMLWriterBase(options) { - var key, ref, ref1, ref2, ref3, ref4, value; - options || (options = {}); - this.pretty = options.pretty || false; - this.allowEmpty = (ref = options.allowEmpty) != null ? ref : false; - if (this.pretty) { - this.indent = (ref1 = options.indent) != null ? ref1 : ' '; - this.newline = (ref2 = options.newline) != null ? ref2 : '\n'; - this.offset = (ref3 = options.offset) != null ? ref3 : 0; - } else { - this.indent = ''; - this.newline = ''; - this.offset = 0; - } - ref4 = options.writer || {}; - for (key in ref4) { - if (!hasProp.call(ref4, key)) continue; - value = ref4[key]; - this[key] = value; - } - } - - XMLWriterBase.prototype.set = function(options) { - var key, ref, value; - options || (options = {}); - if ("pretty" in options) { - this.pretty = options.pretty; - } - if ("allowEmpty" in options) { - this.allowEmpty = options.allowEmpty; - } - if (this.pretty) { - this.indent = "indent" in options ? options.indent : ' '; - this.newline = "newline" in options ? options.newline : '\n'; - this.offset = "offset" in options ? options.offset : 0; - } else { - this.indent = ''; - this.newline = ''; - this.offset = 0; - } - ref = options.writer || {}; - for (key in ref) { - if (!hasProp.call(ref, key)) continue; - value = ref[key]; - this[key] = value; - } - return this; - }; - - XMLWriterBase.prototype.space = function(level) { - if (this.pretty) { - return new Array((level || 0) + this.offset + 1).join(this.indent); - } else { - return ''; - } - }; - - return XMLWriterBase; - - })(); - -}).call(this); diff --git a/node_modules/xmlbuilder/lib/index.js b/node_modules/xmlbuilder/lib/index.js index de7ee8f32..be80d7cc9 100644 --- a/node_modules/xmlbuilder/lib/index.js +++ b/node_modules/xmlbuilder/lib/index.js @@ -1,53 +1,14 @@ -// Generated by CoffeeScript 1.10.0 +// Generated by CoffeeScript 1.9.1 (function() { - var XMLDocument, XMLDocumentCB, XMLStreamWriter, XMLStringWriter, assign, isFunction, ref; + var XMLBuilder, assign; - ref = require('./Utility'), assign = ref.assign, isFunction = ref.isFunction; + assign = require('lodash/assign'); - XMLDocument = require('./XMLDocument'); - - XMLDocumentCB = require('./XMLDocumentCB'); - - XMLStringWriter = require('./XMLStringWriter'); - - XMLStreamWriter = require('./XMLStreamWriter'); + XMLBuilder = require('./XMLBuilder'); module.exports.create = function(name, xmldec, doctype, options) { - var doc, root; - if (name == null) { - throw new Error("Root element needs a name"); - } options = assign({}, xmldec, doctype, options); - doc = new XMLDocument(options); - root = doc.element(name); - if (!options.headless) { - doc.declaration(options); - if ((options.pubID != null) || (options.sysID != null)) { - doc.doctype(options); - } - } - return root; - }; - - module.exports.begin = function(options, onData, onEnd) { - var ref1; - if (isFunction(options)) { - ref1 = [options, onData], onData = ref1[0], onEnd = ref1[1]; - options = {}; - } - if (onData) { - return new XMLDocumentCB(options, onData, onEnd); - } else { - return new XMLDocument(options); - } - }; - - module.exports.stringWriter = function(options) { - return new XMLStringWriter(options); - }; - - module.exports.streamWriter = function(stream, options) { - return new XMLStreamWriter(stream, options); + return new XMLBuilder(name, options).root(); }; }).call(this); |