scratch – Diff between revs 75 and 125

Subversion Repositories:
Rev:
Show entire fileIgnore whitespace
Rev 75 Rev 125
Line 51... Line 51...
51 })(); 51 })();
Line 52... Line 52...
52   52  
Line 53... Line 53...
53 module.exports = Dumper; 53 module.exports = Dumper;
54   54  
Line 55... Line 55...
55   55  
Line 56... Line 56...
56 },{"./Inline":5,"./Utils":9}],2:[function(require,module,exports){ 56 },{"./Inline":6,"./Utils":10}],2:[function(require,module,exports){
Line 109... Line 109...
109 })(); 109 })();
Line 110... Line 110...
110   110  
Line 111... Line 111...
111 module.exports = Escaper; 111 module.exports = Escaper;
112   112  
113   113  
114 },{"./Pattern":7}],3:[function(require,module,exports){ 114 },{"./Pattern":8}],3:[function(require,module,exports){
Line 115... Line 115...
115 var DumpException, 115 var DumpException,
Line 168... Line 168...
168   168  
Line 169... Line 169...
169 module.exports = ParseException; 169 module.exports = ParseException;
-   170  
-   171  
-   172 },{}],5:[function(require,module,exports){
-   173 var ParseMore,
-   174 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; },
-   175 hasProp = {}.hasOwnProperty;
-   176  
-   177 ParseMore = (function(superClass) {
-   178 extend(ParseMore, superClass);
-   179  
-   180 function ParseMore(message, parsedLine, snippet) {
-   181 this.message = message;
-   182 this.parsedLine = parsedLine;
-   183 this.snippet = snippet;
-   184 }
-   185  
-   186 ParseMore.prototype.toString = function() {
-   187 if ((this.parsedLine != null) && (this.snippet != null)) {
-   188 return '<ParseMore> ' + this.message + ' (line ' + this.parsedLine + ': \'' + this.snippet + '\')';
-   189 } else {
-   190 return '<ParseMore> ' + this.message;
-   191 }
-   192 };
-   193  
-   194 return ParseMore;
-   195  
-   196 })(Error);
-   197  
-   198 module.exports = ParseMore;
170   199  
171   200  
Line 172... Line 201...
172 },{}],5:[function(require,module,exports){ 201 },{}],6:[function(require,module,exports){
Line 173... Line 202...
173 var DumpException, Escaper, Inline, ParseException, Pattern, Unescaper, Utils, 202 var DumpException, Escaper, Inline, ParseException, ParseMore, Pattern, Unescaper, Utils,
Line 181... Line 210...
181   210  
Line 182... Line 211...
182 Utils = require('./Utils'); 211 Utils = require('./Utils');
Line -... Line 212...
-   212  
-   213 ParseException = require('./Exception/ParseException');
183   214  
Line 184... Line 215...
184 ParseException = require('./Exception/ParseException'); 215 ParseMore = require('./Exception/ParseMore');
185   216  
Line 389... Line 420...
389   420  
390 Inline.parseQuotedScalar = function(scalar, context) { 421 Inline.parseQuotedScalar = function(scalar, context) {
391 var i, match, output; 422 var i, match, output;
392 i = context.i; 423 i = context.i;
393 if (!(match = this.PATTERN_QUOTED_SCALAR.exec(scalar.slice(i)))) { 424 if (!(match = this.PATTERN_QUOTED_SCALAR.exec(scalar.slice(i)))) {
394 throw new ParseException('Malformed inline YAML string (' + scalar.slice(i) + ').'); 425 throw new ParseMore('Malformed inline YAML string (' + scalar.slice(i) + ').');
395 } 426 }
396 output = match[0].substr(1, match[0].length - 2); 427 output = match[0].substr(1, match[0].length - 2);
397 if ('"' === scalar.charAt(i)) { 428 if ('"' === scalar.charAt(i)) {
398 output = Unescaper.unescapeDoubleQuotedString(output); 429 output = Unescaper.unescapeDoubleQuotedString(output);
Line 441... Line 472...
441 output.push(value); 472 output.push(value);
442 --i; 473 --i;
443 } 474 }
444 ++i; 475 ++i;
445 } 476 }
446 throw new ParseException('Malformed inline YAML string ' + sequence); 477 throw new ParseMore('Malformed inline YAML string ' + sequence);
447 }; 478 };
Line 448... Line 479...
448   479  
449 Inline.parseMapping = function(mapping, context) { 480 Inline.parseMapping = function(mapping, context) {
450 var done, i, key, len, output, shouldContinueWhileLoop, value; 481 var done, i, key, len, output, shouldContinueWhileLoop, value;
Line 509... Line 540...
509 if (done) { 540 if (done) {
510 break; 541 break;
511 } 542 }
512 } 543 }
513 } 544 }
514 throw new ParseException('Malformed inline YAML string ' + mapping); 545 throw new ParseMore('Malformed inline YAML string ' + mapping);
515 }; 546 };
Line 516... Line 547...
516   547  
517 Inline.evaluateScalar = function(scalar, context) { 548 Inline.evaluateScalar = function(scalar, context) {
518 var cast, date, exceptionOnInvalidType, firstChar, firstSpace, firstWord, objectDecoder, raw, scalarLower, subValue, trimmedScalar; 549 var cast, date, exceptionOnInvalidType, firstChar, firstSpace, firstWord, objectDecoder, raw, scalarLower, subValue, trimmedScalar;
Line 652... Line 683...
652 })(); 683 })();
Line 653... Line 684...
653   684  
Line 654... Line 685...
654 module.exports = Inline; 685 module.exports = Inline;
655   686  
Line 656... Line 687...
656   687  
Line 657... Line 688...
657 },{"./Escaper":2,"./Exception/DumpException":3,"./Exception/ParseException":4,"./Pattern":7,"./Unescaper":8,"./Utils":9}],6:[function(require,module,exports){ 688 },{"./Escaper":2,"./Exception/DumpException":3,"./Exception/ParseException":4,"./Exception/ParseMore":5,"./Pattern":8,"./Unescaper":9,"./Utils":10}],7:[function(require,module,exports){
Line 658... Line 689...
658 var Inline, ParseException, Parser, Pattern, Utils; 689 var Inline, ParseException, ParseMore, Parser, Pattern, Utils;
Line 659... Line 690...
659   690  
Line -... Line 691...
-   691 Inline = require('./Inline');
-   692  
660 Inline = require('./Inline'); 693 Pattern = require('./Pattern');
661   694  
Line 662... Line 695...
662 Pattern = require('./Pattern'); 695 Utils = require('./Utils');
Line 682... Line 715...
682   715  
Line 683... Line 716...
683 Parser.prototype.PATTERN_INDENT_SPACES = new Pattern('^ +'); 716 Parser.prototype.PATTERN_INDENT_SPACES = new Pattern('^ +');
Line 684... Line 717...
684   717  
Line 685... Line 718...
685 Parser.prototype.PATTERN_TRAILING_LINES = new Pattern('(\n*)$'); 718 Parser.prototype.PATTERN_TRAILING_LINES = new Pattern('(\n*)$');
Line 686... Line 719...
686   719  
Line 687... Line 720...
687 Parser.prototype.PATTERN_YAML_HEADER = new Pattern('^\\%YAML[: ][\\d\\.]+.*\n'); 720 Parser.prototype.PATTERN_YAML_HEADER = new Pattern('^\\%YAML[: ][\\d\\.]+.*\n', 'm');
Line 688... Line 721...
688   721  
Line 689... Line 722...
689 Parser.prototype.PATTERN_LEADING_COMMENTS = new Pattern('^(\\#.*?\n)+'); 722 Parser.prototype.PATTERN_LEADING_COMMENTS = new Pattern('^(\\#.*?\n)+', 'm');
Line 977... Line 1010...
977 while (this.moveToNextLine()) { 1010 while (this.moveToNextLine()) {
978 indent = this.getCurrentLineIndentation(); 1011 indent = this.getCurrentLineIndentation();
979 if (indent === newIndent) { 1012 if (indent === newIndent) {
980 removeComments = !removeCommentsPattern.test(this.currentLine); 1013 removeComments = !removeCommentsPattern.test(this.currentLine);
981 } 1014 }
982 if (isItUnindentedCollection && !this.isStringUnIndentedCollectionItem(this.currentLine) && indent === newIndent) { -  
983 this.moveToPreviousLine(); 1015 if (removeComments && this.isCurrentLineComment()) {
984 break; 1016 continue;
985 } 1017 }
986 if (this.isCurrentLineBlank()) { 1018 if (this.isCurrentLineBlank()) {
987 data.push(this.currentLine.slice(newIndent)); 1019 data.push(this.currentLine.slice(newIndent));
988 continue; 1020 continue;
989 } 1021 }
990 if (removeComments && this.isCurrentLineComment()) { 1022 if (isItUnindentedCollection && !this.isStringUnIndentedCollectionItem(this.currentLine) && indent === newIndent) {
991 if (indent === newIndent) { 1023 this.moveToPreviousLine();
992 continue; -  
993 } 1024 break;
994 } 1025 }
995 if (indent >= newIndent) { 1026 if (indent >= newIndent) {
996 data.push(this.currentLine.slice(newIndent)); 1027 data.push(this.currentLine.slice(newIndent));
997 } else if (Utils.ltrim(this.currentLine).charAt(0) === '#') { 1028 } else if (Utils.ltrim(this.currentLine).charAt(0) === '#') {
Line 1017... Line 1048...
1017 Parser.prototype.moveToPreviousLine = function() { 1048 Parser.prototype.moveToPreviousLine = function() {
1018 this.currentLine = this.lines[--this.currentLineNb]; 1049 this.currentLine = this.lines[--this.currentLineNb];
1019 }; 1050 };
Line 1020... Line 1051...
1020   1051  
1021 Parser.prototype.parseValue = function(value, exceptionOnInvalidType, objectDecoder) { 1052 Parser.prototype.parseValue = function(value, exceptionOnInvalidType, objectDecoder) {
1022 var e, error, error1, foldedIndent, matches, modifiers, pos, ref, ref1, val; 1053 var e, error, foldedIndent, matches, modifiers, pos, ref, ref1, val;
1023 if (0 === value.indexOf('*')) { 1054 if (0 === value.indexOf('*')) {
1024 pos = value.indexOf('#'); 1055 pos = value.indexOf('#');
1025 if (pos !== -1) { 1056 if (pos !== -1) {
1026 value = value.substr(1, pos - 2); 1057 value = value.substr(1, pos - 2);
Line 1044... Line 1075...
1044 return Inline.parseScalar(matches.type + ' ' + val); 1075 return Inline.parseScalar(matches.type + ' ' + val);
1045 } else { 1076 } else {
1046 return val; 1077 return val;
1047 } 1078 }
1048 } 1079 }
1049 try { -  
1050 return Inline.parse(value, exceptionOnInvalidType, objectDecoder); 1080 if ((ref1 = value.charAt(0)) === '[' || ref1 === '{' || ref1 === '"' || ref1 === "'") {
1051 } catch (error) { 1081 while (true) {
1052 e = error; -  
1053 if (((ref1 = value.charAt(0)) === '[' || ref1 === '{') && e instanceof ParseException && this.isNextLineIndented()) { -  
1054 value += "\n" + this.getNextEmbedBlock(); -  
1055 try { 1082 try {
1056 return Inline.parse(value, exceptionOnInvalidType, objectDecoder); 1083 return Inline.parse(value, exceptionOnInvalidType, objectDecoder);
1057 } catch (error1) { 1084 } catch (error) {
1058 e = error1; 1085 e = error;
-   1086 if (e instanceof ParseMore && this.moveToNextLine()) {
-   1087 value += "\n" + Utils.trim(this.currentLine, ' ');
-   1088 } else {
1059 e.parsedLine = this.getRealCurrentLineNb() + 1; 1089 e.parsedLine = this.getRealCurrentLineNb() + 1;
1060 e.snippet = this.currentLine; 1090 e.snippet = this.currentLine;
1061 throw e; 1091 throw e;
-   1092 }
1062 } 1093 }
1063 } else { -  
1064 e.parsedLine = this.getRealCurrentLineNb() + 1; -  
1065 e.snippet = this.currentLine; -  
1066 throw e; -  
1067 } 1094 }
-   1095 } else {
-   1096 if (this.isNextLineIndented()) {
-   1097 value += "\n" + this.getNextEmbedBlock();
-   1098 }
-   1099 return Inline.parse(value, exceptionOnInvalidType, objectDecoder);
1068 } 1100 }
1069 }; 1101 };
Line 1070... Line 1102...
1070   1102  
1071 Parser.prototype.parseFoldedScalar = function(separator, indicator, indentation) { 1103 Parser.prototype.parseFoldedScalar = function(separator, indicator, indentation) {
Line 1256... Line 1288...
1256 })(); 1288 })();
Line 1257... Line 1289...
1257   1289  
Line 1258... Line 1290...
1258 module.exports = Parser; 1290 module.exports = Parser;
1259   1291  
Line 1260... Line 1292...
1260   1292  
1261 },{"./Exception/ParseException":4,"./Inline":5,"./Pattern":7,"./Utils":9}],7:[function(require,module,exports){ 1293 },{"./Exception/ParseException":4,"./Exception/ParseMore":5,"./Inline":6,"./Pattern":8,"./Utils":10}],8:[function(require,module,exports){
Line 1364... Line 1396...
1364 } 1396 }
1365 this.regex.lastIndex = 0; 1397 this.regex.lastIndex = 0;
1366 count = 0; 1398 count = 0;
1367 while (this.regex.test(str) && (limit === 0 || count < limit)) { 1399 while (this.regex.test(str) && (limit === 0 || count < limit)) {
1368 this.regex.lastIndex = 0; 1400 this.regex.lastIndex = 0;
1369 str = str.replace(this.regex, ''); 1401 str = str.replace(this.regex, replacement);
1370 count++; 1402 count++;
1371 } 1403 }
1372 return [str, count]; 1404 return [str, count];
1373 }; 1405 };
Line 1377... Line 1409...
1377 })(); 1409 })();
Line 1378... Line 1410...
1378   1410  
Line 1379... Line 1411...
1379 module.exports = Pattern; 1411 module.exports = Pattern;
1380   1412  
Line 1381... Line 1413...
1381   1413  
Line 1382... Line 1414...
1382 },{}],8:[function(require,module,exports){ 1414 },{}],9:[function(require,module,exports){
Line 1462... Line 1494...
1462 })(); 1494 })();
Line 1463... Line 1495...
1463   1495  
Line 1464... Line 1496...
1464 module.exports = Unescaper; 1496 module.exports = Unescaper;
1465   1497  
-   1498  
Line 1466... Line 1499...
1466   1499 },{"./Pattern":8,"./Utils":10}],10:[function(require,module,exports){
Line 1467... Line 1500...
1467 },{"./Pattern":7,"./Utils":9}],9:[function(require,module,exports){ 1500 var Pattern, Utils,
1468 var Pattern, Utils; 1501 hasProp = {}.hasOwnProperty;
Line 1491... Line 1524...
1491 Utils.trim = function(str, _char) { 1524 Utils.trim = function(str, _char) {
1492 var regexLeft, regexRight; 1525 var regexLeft, regexRight;
1493 if (_char == null) { 1526 if (_char == null) {
1494 _char = '\\s'; 1527 _char = '\\s';
1495 } 1528 }
1496 return str.trim(); -  
1497 regexLeft = this.REGEX_LEFT_TRIM_BY_CHAR[_char]; 1529 regexLeft = this.REGEX_LEFT_TRIM_BY_CHAR[_char];
1498 if (regexLeft == null) { 1530 if (regexLeft == null) {
1499 this.REGEX_LEFT_TRIM_BY_CHAR[_char] = regexLeft = new RegExp('^' + _char + '' + _char + '*'); 1531 this.REGEX_LEFT_TRIM_BY_CHAR[_char] = regexLeft = new RegExp('^' + _char + '' + _char + '*');
1500 } 1532 }
1501 regexLeft.lastIndex = 0; 1533 regexLeft.lastIndex = 0;
Line 1532... Line 1564...
1532 regexRight.lastIndex = 0; 1564 regexRight.lastIndex = 0;
1533 return str.replace(regexRight, ''); 1565 return str.replace(regexRight, '');
1534 }; 1566 };
Line 1535... Line 1567...
1535   1567  
1536 Utils.isEmpty = function(value) { 1568 Utils.isEmpty = function(value) {
-   1569 return !value || value === '' || value === '0' || (value instanceof Array && value.length === 0) || this.isEmptyObject(value);
-   1570 };
-   1571  
-   1572 Utils.isEmptyObject = function(value) {
-   1573 var k;
-   1574 return value instanceof Object && ((function() {
-   1575 var results;
-   1576 results = [];
-   1577 for (k in value) {
-   1578 if (!hasProp.call(value, k)) continue;
-   1579 results.push(k);
-   1580 }
-   1581 return results;
1537 return !value || value === '' || value === '0' || (value instanceof Array && value.length === 0); 1582 })()).length === 0;
Line 1538... Line 1583...
1538 }; 1583 };
1539   1584  
1540 Utils.subStrCount = function(string, subString, start, length) { 1585 Utils.subStrCount = function(string, subString, start, length) {
Line 1664... Line 1709...
1664 tz_offset *= -1; 1709 tz_offset *= -1;
1665 } 1710 }
1666 } 1711 }
1667 date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction)); 1712 date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
1668 if (tz_offset) { 1713 if (tz_offset) {
1669 date.setTime(date.getTime() + tz_offset); 1714 date.setTime(date.getTime() - tz_offset);
1670 } 1715 }
1671 return date; 1716 return date;
1672 }; 1717 };
Line 1673... Line 1718...
1673   1718  
Line 1748... Line 1793...
1748 })(); 1793 })();
Line 1749... Line 1794...
1749   1794  
Line 1750... Line 1795...
1750 module.exports = Utils; 1795 module.exports = Utils;
1751   1796  
Line 1752... Line 1797...
1752   1797  
Line 1753... Line 1798...
1753 },{"./Pattern":7}],10:[function(require,module,exports){ 1798 },{"./Pattern":8}],11:[function(require,module,exports){
Line 1820... Line 1865...
1820 yaml = new Dumper(); 1865 yaml = new Dumper();
1821 yaml.indentation = indent; 1866 yaml.indentation = indent;
1822 return yaml.dump(input, inline, 0, exceptionOnInvalidType, objectEncoder); 1867 return yaml.dump(input, inline, 0, exceptionOnInvalidType, objectEncoder);
1823 }; 1868 };
Line 1824... Line -...
1824   -  
1825 Yaml.register = function() { -  
1826 var require_handler; -  
1827 require_handler = function(module, filename) { -  
1828 return module.exports = YAML.parseFile(filename); -  
1829 }; -  
1830 if ((typeof require !== "undefined" && require !== null ? require.extensions : void 0) != null) { -  
1831 require.extensions['.yml'] = require_handler; -  
1832 return require.extensions['.yaml'] = require_handler; -  
1833 } -  
1834 }; -  
1835   1869  
1836 Yaml.stringify = function(input, inline, indent, exceptionOnInvalidType, objectEncoder) { 1870 Yaml.stringify = function(input, inline, indent, exceptionOnInvalidType, objectEncoder) {
1837 return this.dump(input, inline, indent, exceptionOnInvalidType, objectEncoder); 1871 return this.dump(input, inline, indent, exceptionOnInvalidType, objectEncoder);
Line 1838... Line 1872...
1838 }; 1872 };
Line 1854... Line 1888...
1854 } 1888 }
Line 1855... Line 1889...
1855   1889  
Line 1856... Line 1890...
1856 module.exports = Yaml; 1890 module.exports = Yaml;