summaryrefslogtreecommitdiff
path: root/bin/yaml.min.js
diff options
context:
space:
mode:
Diffstat (limited to 'bin/yaml.min.js')
-rw-r--r--bin/yaml.min.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/bin/yaml.min.js b/bin/yaml.min.js
new file mode 100644
index 0000000..a9791c2
--- /dev/null
+++ b/bin/yaml.min.js
@@ -0,0 +1,22 @@
+/*
+Copyright (c) 2010 Jeremy Faivre
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is furnished
+to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+var YamlParseException=function(e,t,n,r){this.rawMessage=e,this.parsedLine=t!==undefined?t:-1,this.snippet=n!==undefined?n:null,this.parsedFile=r!==undefined?r:null,this.updateRepr(),this.message=e};YamlParseException.prototype={name:"YamlParseException",message:null,parsedFile:null,parsedLine:-1,snippet:null,rawMessage:null,isDefined:function(e){return e!=undefined&&e!=null},getSnippet:function(){return this.snippet},setSnippet:function(e){this.snippet=e,this.updateRepr()},getParsedFile:function(){return this.parsedFile},setParsedFile:function(e){this.parsedFile=e,this.updateRepr()},getParsedLine:function(){return this.parsedLine},setParsedLine:function(e){this.parsedLine=e,this.updateRepr()},updateRepr:function(){this.message=this.rawMessage,dot=!1,"."===this.message.charAt(this.message.length-1)&&(this.message=this.message.substring(0,this.message.length-1),dot=!0),null!==this.parsedFile&&(this.message+=" in "+JSON.stringify(this.parsedFile)),this.parsedLine>=0&&(this.message+=" at line "+this.parsedLine),this.snippet&&(this.message+=' (near "'+this.snippet+'")'),dot&&(this.message+=".")}};var isNode=!1,Yaml=function(){};Yaml.prototype={parseFile:function(e,t){if(t==null){var n=this.getFileContents(e),r=null;try{r=this.parse(n)}catch(i){throw i instanceof YamlParseException&&i.setParsedFile(e),i}return r}this.getFileContents(e,function(e){t((new Yaml).parse(e))})},parse:function(e){var t=new YamlParser;return t.parse(e)},dump:function(e,t){t==null&&(t=2);var n=new YamlDumper;return n.dump(e,t)},getXHR:function(){if(window.XMLHttpRequest)return new XMLHttpRequest;if(window.ActiveXObject){var e=["Msxml2.XMLHTTP.6.0","Msxml2.XMLHTTP.3.0","Msxml2.XMLHTTP","Microsoft.XMLHTTP"];for(var t=0;t<4;t++)try{return new ActiveXObject(e[t])}catch(n){}}return null},getFileContents:function(e,t){if(isNode){var n=require("fs");if(t==null){var r=n.readFileSync(e);return r==null?null:""+r}n.readFile(e,function(e,n){e?t(null):t(n)})}else{var i=this.getXHR();if(t==null)return i.open("GET",e,!1),i.send(null),i.status==200||i.status==0?i.responseText:null;i.onreadystatechange=function(){i.readyState==4&&(i.status==200||i.status==0?t(i.responseText):t(null))},i.open("GET",e,!0),i.send(null)}}};var YAML={stringify:function(e,t){return(new Yaml).dump(e,t)},parse:function(e){return(new Yaml).parse(e)},load:function(e,t){return(new Yaml).parseFile(e,t)}};typeof exports!="undefined"&&typeof module!="undefined"&&module.exports&&(exports=module.exports=YAML,isNode=!0,function(){var e=function(e,t){e.exports=YAML.load(t)};undefined!==require.extensions&&(require.extensions[".yml"]=e,require.extensions[".yaml"]=e)}());var YamlInline=function(){};YamlInline.prototype={i:null,parse:function(e){var t=null;e=this.trim(e);if(0==e.length)return"";switch(e.charAt(0)){case"[":t=this.parseSequence(e);break;case"{":t=this.parseMapping(e);break;default:t=this.parseScalar(e);if(e.substr(this.i).replace(/^\s+#.*$/,""))throw new YamlParseException('Unexpected characters near "'+e.substr(this.i)+'".')}return t},dump:function(e){if(undefined==e||null==e)return"null";if(e instanceof Date)return e.toISOString();if(typeof e=="object")return this.dumpObject(e);if(typeof e=="boolean")return e?"true":"false";if(/^\d+$/.test(e))return typeof e=="string"?"'"+e+"'":parseInt(e);if(this.isNumeric(e))return typeof e=="string"?"'"+e+"'":parseFloat(e);if(typeof e=="number")return e==Infinity?".Inf":e==-Infinity?"-.Inf":isNaN(e)?".NAN":e;var t=new YamlEscaper;return t.requiresDoubleQuoting(e)?t.escapeWithDoubleQuotes(e):t.requiresSingleQuoting(e)?t.escapeWithSingleQuotes(e):""==e?"":this.getTimestampRegex().test(e)?"'"+e+"'":this.inArray(e.toLowerCase(),["null","~","true","false"])?"'"+e+"'":e},dumpObject:function(e){var t=this.getKeys(e),n=null,r,i=t.length;if(e instanceof Array){n=[];for(r=0;r<i;r++)n.push(this.dump(e[t[r]]));return"["+n.join(", ")+"]"}n=[];for(r=0;r<i;r++)n.push(this.dump(t[r])+": "+this.dump(e[t[r]]));return"{ "+n.join(", ")+" }"},parseScalar:function(e,t,n,r,i){t==undefined&&(t=null),n==undefined&&(n=['"',"'"]),r==undefined&&(r=0),i==undefined&&(i=!0);var s=null,o=null,u=null;if(this.inArray(e[r],n)){s=this.parseQuotedScalar(e,r),r=this.i;if(null!==t){var a=e.substr(r).replace(/^\s+/,"");if(!this.inArray(a.charAt(0),t))throw new YamlParseException("Unexpected characters ("+e.substr(r)+").")}}else{if(!t)s=(e+"").substring(r),r+=s.length,o=s.indexOf(" #"),o!=-1&&(s=s.substr(0,o).replace(/\s+$/g,""));else{if(!(u=(new RegExp("^(.+?)("+t.join("|")+")")).exec((e+"").substring(r))))throw new YamlParseException("Malformed inline YAML string ("+e+").");s=u[1],r+=s.length}s=i?this.evaluateScalar(s):s}return this.i=r,s},parseQuotedScalar:function(e,t){var n=null;if(!(n=(new RegExp("^"+YamlInline.REGEX_QUOTED_STRING)).exec((e+"").substring(t))))throw new YamlParseException("Malformed inline YAML string ("+(e+"").substring(t)+").");var r=n[0].substr(1,n[0].length-2),i=new YamlUnescaper;return'"'==(e+"").charAt(t)?r=i.unescapeDoubleQuotedString(r):r=i.unescapeSingleQuotedString(r),t+=n[0].length,this.i=t,r},parseSequence:function(e,t){t==undefined&&(t=0);var n=[],r=e.length;t+=1;while(t<r){switch(e.charAt(t)){case"[":n.push(this.parseSequence(e,t)),t=this.i;break;case"{":n.push(this.parseMapping(e,t)),t=this.i;break;case"]":return this.i=t,n;case",":case" ":break;default:isQuoted=this.inArray(e.charAt(t),['"',"'"]);var i=this.parseScalar(e,[",","]"],['"',"'"],t);t=this.i;if(!isQuoted&&(i+"").indexOf(": ")!=-1)try{i=this.parseMapping("{"+i+"}")}catch(s){if(!(s instanceof YamlParseException))throw s}n.push(i),t--}t++}throw new YamlParseException('Malformed inline YAML string "'+e+'"')},parseMapping:function(e,t){t==undefined&&(t=0);var n={},r=e.length;t+=1;var i=!1,s=!1;while(t<r){s=!1;switch(e.charAt(t)){case" ":case",":t++,s=!0;break;case"}":return this.i=t,n}if(s)continue;var o=this.parseScalar(e,[":"," "],['"',"'"],t,!1);t=this.i,i=!1;while(t<r){switch(e.charAt(t)){case"[":n[o]=this.parseSequence(e,t),t=this.i,i=!0;break;case"{":n[o]=this.parseMapping(e,t),t=this.i,i=!0;break;case":":case" ":break;default:n[o]=this.parseScalar(e,[",","}"],['"',"'"],t),t=this.i,i=!0,t--}++t;if(i){s=!0;break}}if(s)continue}throw new YamlParseException('Malformed inline YAML string "'+e+'"')},evaluateScalar:function(e){e=this.trim(e);var t=null,n=null;return"null"==e.toLowerCase()||""==e||"~"==e?null:(e+"").indexOf("!str ")==0?(""+e).substring(5):(e+"").indexOf("! ")==0?parseInt(this.parseScalar((e+"").substr(2))):/^\d+$/.test(e)?(t=e,n=parseInt(e),"0"==e.charAt(0)?this.octdec(e):""+t==""+n?n:t):"true"==(e+"").toLowerCase()?!0:"false"==(e+"").toLowerCase()?!1:this.isNumeric(e)?"0x"==(e+"").substr(0,2)?this.hexdec(e):parseFloat(e):e.toLowerCase()==".inf"?Infinity:e.toLowerCase()==".nan"?NaN:e.toLowerCase()=="-.inf"?-Infinity:/^(-|\+)?[0-9,]+(\.[0-9]+)?$/.test(e)?parseFloat(e.split(",").join("")):this.getTimestampRegex().test(e)?new Date(this.strtotime(e)):""+e},getTimestampRegex:function(){return new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:(?:[Tt]|[ ]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:.([0-9]*))?(?:[ ]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?)?$","gi")},trim:function(e){return(e+"").replace(/^\s+/,"").replace(/\s+$/,"")},isNumeric:function(e){return e-0==e&&e.length>0&&e.replace(/\s+/g,"")!=""},inArray:function(e,t){var n,r=t.length;for(n=0;n<r;n++)if(e==t[n])return!0;return!1},getKeys:function(e){var t=[];for(var n in e)e.hasOwnProperty(n)&&t.push(n);return t},octdec:function(e){return parseInt((e+"").replace(/[^0-7]/gi,""),8)},hexdec:function(e){return e=this.trim(e),(e+"").substr(0,2)=="0x"&&(e=(e+"").substring(2)),parseInt((e+"").replace(/[^a-f0-9]/gi,""),16)},strtotime:function(e,t){var n,r,i,s,o="";e=(e+"").replace(/\s{2,}|^\s|\s$/g," ").replace(/[\t\r\n]/g,"");if(e==="now")return t===null||isNaN(t)?(new Date).getTime()||0:t||0;if(!isNaN(o=Date.parse(e)))return o||0;t?t=new Date(t):t=new Date,e=e.toLowerCase();var u={day:{sun:0,mon:1,tue:2,wed:3,thu:4,fri:5,sat:6},mon:["jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"]},a=function(e){var n=e[2]&&e[2]==="ago",r=(r=e[0]==="last"?-1:1)*(n?-1:1);switch(e[0]){case"last":case"next":switch(e[1].substring(0,3)){case"yea":t.setFullYear(t.getFullYear()+r);break;case"wee":t.setDate(t.getDate()+r*7);break;case"day":t.setDate(t.getDate()+r);break;case"hou":t.setHours(t.getHours()+r);break;case"min":t.setMinutes(t.getMinutes()+r);break;case"sec":t.setSeconds(t.getSeconds()+r);break;case"mon":if(e[1]==="month"){t.setMonth(t.getMonth()+r);break};default:var i=u.day[e[1].substring(0,3)];if(typeof i!="undefined"){var s=i-t.getDay();s===0?s=7*r:s>0?e[0]==="last"&&(s-=7):e[0]==="next"&&(s+=7),t.setDate(t.getDate()+s),t.setHours(0,0,0,0)}}break;default:if(!/\d+/.test(e[0]))return!1;r*=parseInt(e[0],10);switch(e[1].substring(0,3)){case"yea":t.setFullYear(t.getFullYear()+r);break;case"mon":t.setMonth(t.getMonth()+r);break;case"wee":t.setDate(t.getDate()+r*7);break;case"day":t.setDate(t.getDate()+r);break;case"hou":t.setHours(t.getHours()+r);break;case"min":t.setMinutes(t.getMinutes()+r);break;case"sec":t.setSeconds(t.getSeconds()+r)}}return!0};i=e.match(/^(\d{2,4}-\d{2}-\d{2})(?:\s(\d{1,2}:\d{2}(:\d{2})?)?(?:\.(\d+))?)?$/);if(i!==null)return i[2]?i[3]||(i[2]+=":00"):i[2]="00:00:00",s=i[1].split(/-/g),s[1]=u.mon[s[1]-1]||s[1],s[0]=+s[0],s[0]=s[0]>=0&&s[0]<=69?"20"+(s[0]<10?"0"+s[0]:s[0]+""):s[0]>=70&&s[0]<=99?"19"+s[0]:s[0]+"",parseInt(this.strtotime(s[2]+" "+s[1]+" "+s[0]+" "+i[2])+(i[4]?i[4]:""),10);var f="([+-]?\\d+\\s(years?|months?|weeks?|days?|hours?|min|minutes?|sec|seconds?|sun\\.?|sunday|mon\\.?|monday|tue\\.?|tuesday|wed\\.?|wednesday|thu\\.?|thursday|fri\\.?|friday|sat\\.?|saturday)|(last|next)\\s(years?|months?|weeks?|days?|hours?|min|minutes?|sec|seconds?|sun\\.?|sunday|mon\\.?|monday|tue\\.?|tuesday|wed\\.?|wednesday|thu\\.?|thursday|fri\\.?|friday|sat\\.?|saturday))(\\sago)?";i=e.match(new RegExp(f,"gi"));if(i===null)return!1;for(n=0,r=i.length;n<r;n++)if(!a(i[n].split(" ")))return!1;return t.getTime()||0}},YamlInline.REGEX_QUOTED_STRING="(?:\"(?:[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*)\"|'(?:[^']*(?:''[^']*)*)')";var YamlParser=function(e){this.offset=e!==undefined?e:0};YamlParser.prototype={offset:0,lines:[],currentLineNb:-1,currentLine:"",refs:{},parse:function(e){this.currentLineNb=-1,this.currentLine="",this.lines=this.cleanup(e).split("\n");var t=null,n=null;while(this.moveToNextLine()){if(this.isCurrentLineEmpty())continue;if(this.currentLine.charAt(0)==" ")throw new YamlParseException("A YAML file cannot contain tabs as indentation.",this.getRealCurrentLineNb()+1,this.currentLine);var r=!1,i=!1,s=!1,o=null,u=null,a=null,f=null,l=null,c=null,h=null,p=null,d=null;if(o=/^\-((\s+)(.+?))?\s*$/.exec(this.currentLine)){if(n&&"mapping"==n)throw new YamlParseException("You cannot define a sequence item when in a mapping",this.getRealCurrentLineNb()+1,this.currentLine);n="sequence",this.isDefined(t)||(t=[]),o={leadspaces:o[2],value:o[3]},this.isDefined(o.value)&&(u=/^&([^ ]+) *(.*)/.exec(o.value))&&(u={ref:u[1],value:u[2]},r=u.ref,o.value=u.value),!this.isDefined(o.value)||""==this.trim(o.value)||o.value.replace(/^ +/,"").charAt(0)=="#"?(a=this.getRealCurrentLineNb()+1,f=new YamlParser(a),f.refs=this.refs,t.push(f.parse(this.getNextEmbedBlock())),this.refs=f.refs):this.isDefined(o.leadspaces)&&" "==o.leadspaces&&(u=(new RegExp("^("+YamlInline.REGEX_QUOTED_STRING+"|[^ '\"{[].*?) *:(\\s+(.+?))?\\s*$")).exec(o.value))?(u={key:u[1],value:u[3]},a=this.getRealCurrentLineNb(),f=new YamlParser(a),f.refs=this.refs,l=o.value,this.isNextLineIndented()||(l+="\n"+this.getNextEmbedBlock(this.getCurrentLineIndentation()+2)),t.push(f.parse(l)),this.refs=f.refs):t.push(this.parseValue(o.value))}else{if(!(o=(new RegExp("^("+YamlInline.REGEX_QUOTED_STRING+"|[^ '\"[{].*?) *:(\\s+(.+?))?\\s*$")).exec(this.currentLine))){if(2==this.lines.length&&this.isEmpty(this.lines[1])){try{e=(new YamlInline).parse(this.lines[0])}catch(v){throw v instanceof YamlParseException&&(v.setParsedLine(this.getRealCurrentLineNb()+1),v.setSnippet(this.currentLine)),v}if(this.isObject(e)){first=e[0];if(typeof e=="string"&&"*"==first.charAt(0)){t=[],p=e.length;for(var g=0;g<p;g++)t.push(this.refs[e[g].substr(1)]);e=t}}return e}throw new YamlParseException("Unable to parse.",this.getRealCurrentLineNb()+1,this.currentLine)}this.isDefined(t)||(t={});if(n&&"sequence"==n)throw new YamlParseException("You cannot define a mapping item when in a sequence",this.getRealCurrentLineNb()+1,this.currentLine);n="mapping",o={key:o[1],value:o[3]};try{c=(new YamlInline).parseScalar(o.key)}catch(v){throw v instanceof YamlParseException&&(v.setParsedLine(this.getRealCurrentLineNb()+1),v.setSnippet(this.currentLine)),v}if("<<"==c)if(this.isDefined(o.value)&&"*"==(o.value+"").charAt(0)){i=o.value.substr(1);if(this.refs[i]==undefined)throw new YamlParseException('Reference "'+e+'" does not exist',this.getRealCurrentLineNb()+1,this.currentLine)}else{this.isDefined(o.value)&&o.value!=""?e=o.value:e=this.getNextEmbedBlock(),a=this.getRealCurrentLineNb()+1,f=new YamlParser(a),f.refs=this.refs,h=f.parse(e),this.refs=f.refs;var m=[];if(!this.isObject(h))throw new YamlParseException("YAML merge keys used with a scalar value instead of an array",this.getRealCurrentLineNb()+1,this.currentLine);if(this.isDefined(h[0])){d=this.reverseArray(h),p=d.length;for(var g=0;g<p;g++){var y=d[g];if(!this.isObject(d[g]))throw new YamlParseException("Merge items must be arrays",this.getRealCurrentLineNb()+1,this.currentLine);m=this.mergeObject(d[g],m)}}else m=this.mergeObject(m,h);s=m}else this.isDefined(o.value)&&(u=/^&([^ ]+) *(.*)/.exec(o.value))&&(u={ref:u[1],value:u[2]},r=u.ref,o.value=u.value);s?t=s:!this.isDefined(o.value)||""==this.trim(o.value)||this.trim(o.value).charAt(0)=="#"?this.isNextLineIndented()&&!this.isNextLineUnIndentedCollection()?t[c]=null:(a=this.getRealCurrentLineNb()+1,f=new YamlParser(a),f.refs=this.refs,t[c]=f.parse(this.getNextEmbedBlock()),this.refs=f.refs):i?t=this.refs[i]:t[c]=this.parseValue(o.value)}if(r)if(t instanceof Array)this.refs[r]=t[t.length-1];else{var b=null;for(var w in t)t.hasOwnProperty(w)&&(b=w);this.refs[r]=t[w]}}return this.isEmpty(t)?null:t},getRealCurrentLineNb:function(){return this.currentLineNb+this.offset},getCurrentLineIndentation:function(){return this.currentLine.length-this.currentLine.replace(/^ +/g,"").length},getNextEmbedBlock:function(e){this.moveToNextLine();var t=null,n=null;if(!this.isDefined(e)){t=this.getCurrentLineIndentation();var r=this.isStringUnIndentedCollectionItem(this.currentLine);if(!this.isCurrentLineEmpty()&&0==t&&!r)throw new YamlParseException("Indentation problem A",this.getRealCurrentLineNb()+1,this.currentLine)}else t=e;var i=[this.currentLine.substr(t)],s=this.isStringUnIndentedCollectionItem(this.currentLine);while(this.moveToNextLine()){if(s&&!this.isStringUnIndentedCollectionItem(this.currentLine)){this.moveToPreviousLine();break}if(this.isCurrentLineEmpty()){this.isCurrentLineBlank()&&i.push(this.currentLine.substr(t));continue}n=this.getCurrentLineIndentation();var o;if(o=/^( *)$/.exec(this.currentLine))i.push(o[1]);else{if(!(n>=t)){if(0==n){this.moveToPreviousLine();break}throw new YamlParseException("Indentation problem B",this.getRealCurrentLineNb()+1,this.currentLine)}i.push(this.currentLine.substr(t))}}return i.join("\n")},moveToNextLine:function(){return this.currentLineNb>=this.lines.length-1?!1:(this.currentLineNb++,this.currentLine=this.lines[this.currentLineNb],!0)},moveToPreviousLine:function(){this.currentLineNb--,this.currentLine=this.lines[this.currentLineNb]},parseValue:function(e){if("*"==(e+"").charAt(0)){this.trim(e).charAt(0)=="#"?e=(e+"").substr(1,e.indexOf("#")-2):e=(e+"").substr(1);if(this.refs[e]==undefined)throw new YamlParseException('Reference "'+e+'" does not exist',this.getRealCurrentLineNb()+1,this.currentLine);return this.refs[e]}var t=null;if(t=/^(\||>)(\+|\-|\d+|\+\d+|\-\d+|\d+\+|\d+\-)?( +#.*)?$/.exec(e)){t={separator:t[1],modifiers:t[2],comments:t[3]};var n=this.isDefined(t.modifiers)?t.modifiers:"";return this.parseFoldedScalar(t.separator,n.replace(/\d+/g,""),Math.abs(parseInt(n)))}try{return(new YamlInline).parse(e)}catch(r){throw r instanceof YamlParseException&&(r.setParsedLine(this.getRealCurrentLineNb()+1),r.setSnippet(this.currentLine)),r}},parseFoldedScalar:function(e,t,n){t==undefined&&(t=""),n==undefined&&(n=0),e="|"==e?"\n":" ";var r="",i=null,s=this.moveToNextLine();while(s&&this.isCurrentLineBlank())r+="\n",s=this.moveToNextLine();if(!s)return"";var o=null;if(!(o=(new RegExp("^("+(n?this.strRepeat(" ",n):" +")+")(.*)$")).exec(this.currentLine)))return this.moveToPreviousLine(),"";o={indent:o[1],text:o[2]};var u=o.indent,a=0;r+=o.text+e;while(this.currentLineNb+1<this.lines.length){this.moveToNextLine();if(o=(new RegExp("^( {"+u.length+",})(.+)$")).exec(this.currentLine))o={indent:o[1],text:o[2]}," "==e&&a!=o.indent&&(r=r.substr(0,r.length-1)+"\n"),a=o.indent,i=o.indent.length-u.length,r+=this.strRepeat(" ",i)+o.text+(i!=0?"\n":e);else{if(!(o=/^( *)$/.exec(this.currentLine))){this.moveToPreviousLine();break}r+=o[1].replace(new RegExp("^ {1,"+u.length+"}","g"),"")+"\n"}}" "==e&&(r=r.replace(/ (\n*)$/g,"\n$1"));switch(t){case"":r=r.replace(/\n+$/g,"\n");break;case"+":break;case"-":r=r.replace(/\n+$/g,"")}return r},isNextLineIndented:function(){var e=this.getCurrentLineIndentation(),t=this.moveToNextLine();while(t&&this.isCurrentLineEmpty())t=this.moveToNextLine();if(0==t)return!1;var n=!1;return this.getCurrentLineIndentation()<=e&&(n=!0),this.moveToPreviousLine(),n},isCurrentLineEmpty:function(){return this.isCurrentLineBlank()||this.isCurrentLineComment()},isCurrentLineBlank:function(){return""==this.trim(this.currentLine)},isCurrentLineComment:function(){var e=this.currentLine.replace(/^ +/g,"");return e.charAt(0)=="#"},cleanup:function(e){e=e.split("\r\n").join("\n").split("\r").join("\n"),/\n$/.test(e)||(e+="\n");var t=0,n=/^\%YAML[: ][\d\.]+.*\n/;while(n.test(e))e=e.replace(n,""),t++;this.offset+=t,n=/^(#.*?\n)+/;if(n.test(e)){var r=e.replace(n,"");this.offset+=this.subStrCount(e,"\n")-this.subStrCount(r,"\n"),e=r}return n=/^\-\-\-.*?\n/,n.test(e)&&(r=e.replace(n,""),this.offset+=this.subStrCount(e,"\n")-this.subStrCount(r,"\n"),e=r,e=e.replace(/\.\.\.\s*$/g,"")),e},isNextLineUnIndentedCollection:function(){var e=this.getCurrentLineIndentation(),t=this.moveToNextLine();while(t&&this.isCurrentLineEmpty())t=this.moveToNextLine();if(!1===t)return!1;var n=!1;return this.getCurrentLineIndentation()==e&&this.isStringUnIndentedCollectionItem(this.currentLine)&&(n=!0),this.moveToPreviousLine(),n},isStringUnIndentedCollectionItem:function(e){return 0===this.currentLine.indexOf("- ")},isObject:function(e){return typeof e=="object"&&this.isDefined(e)},isEmpty:function(e){return e==undefined||e==null||e==""||e==0||e=="0"||e==0},isDefined:function(e){return e!=undefined&&e!=null},reverseArray:function(e){var t=[],n=e.length;for(var r=n-1;r>=0;r--)t.push(e[r]);return t},merge:function(e,t){var n={},r;for(r in e)e.hasOwnProperty(r)&&(/^\d+$/.test(r)?n.push(e):n[r]=e[r]);for(r in t)t.hasOwnProperty(r)&&(/^\d+$/.test(r)?n.push(t):n[r]=t[r]);return n},strRepeat:function(e,t){var n,r="";for(n=0;n<t;n++)r+=e;return r},subStrCount:function(e,t,n,r){var i=0;e=""+e,t=""+t,n!=undefined&&(e=e.substr(n)),r!=undefined&&(e=e.substr(0,r));var s=e.length,o=t.length;for(var u=0;u<s;u++)t==e.substr(u,o)&&i++,u+=o-1;return i},trim:function(e){return(e+"").replace(/^ +/,"").replace(/ +$/,"")}},YamlEscaper=function(){},YamlEscaper.prototype={requiresDoubleQuoting:function(e){return(new RegExp(YamlEscaper.REGEX_CHARACTER_TO_ESCAPE)).test(e)},escapeWithDoubleQuotes:function(e){e+="";var t=YamlEscaper.escapees.length,n=YamlEscaper.escaped.length,r=YamlEscaper.escaped;for(var i=0;i<t;++i)i>=n&&r.push("");var s="";return s=e.replace(new RegExp(YamlEscaper.escapees.join("|"),"g"),function(e){for(var n=0;n<t;++n)if(e==YamlEscaper.escapees[n])return r[n]}),'"'+s+'"'},requiresSingleQuoting:function(e){return/[\s'":{}[\],&*#?]|^[-?|<>=!%@`]/.test(e)},escapeWithSingleQuotes:function(e){return"'"+e.replace(/'/g,"''")+"'"}},YamlEscaper.REGEX_CHARACTER_TO_ESCAPE="[\\x00-\\x1f]|…| |
|
",YamlEscaper.escapees=["\\\\",'\\"','"',"\0","","","","","","","","\b"," ","\n"," ","\f","\r","","","","","","","","","","","","","","","","","","","…"," ","
","
"],YamlEscaper.escaped=['\\"',"\\\\",'\\"',"\\0","\\x01","\\x02","\\x03","\\x04","\\x05","\\x06","\\a","\\b","\\t","\\n","\\v","\\f","\\r","\\x0e","\\x0f","\\x10","\\x11","\\x12","\\x13","\\x14","\\x15","\\x16","\\x17","\\x18","\\x19","\\x1a","\\e","\\x1c","\\x1d","\\x1e","\\x1f","\\N","\\_","\\L","\\P"];var YamlUnescaper=function(){};YamlUnescaper.prototype={unescapeSingleQuotedString:function(e){return e.replace(/''/g,"'")},unescapeDoubleQuotedString:function(e){var t=function(e){return(new YamlUnescaper).unescapeCharacter(e)};return e.replace(new RegExp(YamlUnescaper.REGEX_ESCAPED_CHARACTER,"g"),t)},unescapeCharacter:function(e){switch(e.charAt(1)){case"0":return String.fromCharCode(0);case"a":return String.fromCharCode(7);case"b":return String.fromCharCode(8);case"t":return" ";case" ":return" ";case"n":return"\n";case"v":return String.fromCharCode(11);case"f":return String.fromCharCode(12);case"r":return String.fromCharCode(13);case"e":return"";case" ":return" ";case'"':return'"';case"/":return"/";case"\\":return"\\";case"N":return"\0…";case"_":return"\0 ";case"L":return" (";case"P":return" )";case"x":return this.pack("n",(new YamlInline).hexdec(e.substr(2,2)));case"u":return this.pack("n",(new YamlInline).hexdec(e.substr(2,4)));case"U":return this.pack("N",(new YamlInline).hexdec(e.substr(2,8)))}},pack:function(e){var t=0,n=1,r="",i="",s=0,o=[],u,a,f,l,c,h,p,d,v,m,g,y,b,w,E,S,x,T,N,C,k,L,A;while(t<e.length){u=e.charAt(t),a="",t++;while(t<e.length&&e.charAt(t).match(/[\d\*]/)!==null)a+=e.charAt(t),t++;a===""&&(a="1");switch(u){case"n":a==="*"&&(a=arguments.length-n);if(a>arguments.length-n)throw new Error("Warning: pack() Type "+u+": too few arguments");for(s=0;s<a;s++)r+=String.fromCharCode(arguments[n]>>8&255),r+=String.fromCharCode(arguments[n]&255),n++;break;case"N":a==="*"&&(a=arguments.length-n);if(a>arguments.length-n)throw new Error("Warning: pack() Type "+u+": too few arguments");for(s=0;s<a;s++)r+=String.fromCharCode(arguments[n]>>24&255),r+=String.fromCharCode(arguments[n]>>16&255),r+=String.fromCharCode(arguments[n]>>8&255),r+=String.fromCharCode(arguments[n]&255),n++;break;default:throw new Error("Warning: pack() Type "+u+": unknown format code")}}if(n<arguments.length)throw new Error("Warning: pack(): "+(arguments.length-n)+" arguments unused");return r}},YamlUnescaper.REGEX_ESCAPED_CHARACTER='\\\\([0abt nvfre "\\/\\\\N_LP]|x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8})';var YamlDumper=function(){};YamlDumper.prototype={dump:function(e,t,n){t==undefined&&(t=0),n==undefined&&(n=0);var r="",i=n?this.strRepeat(" ",n):"",s;if(t<=0||!this.isObject(e)||this.isEmpty(e))s=new YamlInline,r+=i+s.dump(e);else{var o=!this.arrayEquals(this.getKeys(e),this.range(0,e.length-1)),u;for(var a in e)e.hasOwnProperty(a)&&(u=t-1<=0||!this.isObject(e[a])||this.isEmpty(e[a]),o&&(s=new YamlInline),r+=i+""+(o?s.dump(a)+":":"-")+""+(u?" ":"\n")+""+this.dump(e[a],t-1,u?0:n+2)+""+(u?"\n":""))}return r},strRepeat:function(e,t){var n,r="";for(n=0;n<t;n++)r+=e;return r},isObject:function(e){return this.isDefined(e)&&typeof e=="object"},isEmpty:function(e){var t=e==undefined||e==null||e==""||e==0||e=="0"||e==0;if(!t&&typeof e=="object"&&!(e instanceof Array)){var n=0;for(var r in e)e.hasOwnProperty(r)&&n++;t=!n}return t},isDefined:function(e){return e!=undefined&&e!=null},getKeys:function(e){var t=[];for(var n in e)e.hasOwnProperty(n)&&t.push(n);return t},range:function(e,t){if(e>t)return[];var n=[];for(var r=e;r<=t;r++)n.push(r);return n},arrayEquals:function(e,t){if(e.length!=t.length)return!1;var n=e.length;for(var r=0;r<n;r++)if(e[r]!=t[r])return!1;return!0}}; \ No newline at end of file