scratch – Blame information for rev 75

Subversion Repositories:
Rev:
Rev Author Line No. Line
75 office 1 (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
2 var Dumper, Inline, Utils;
3  
4 Utils = require('./Utils');
5  
6 Inline = require('./Inline');
7  
8 Dumper = (function() {
9 function Dumper() {}
10  
11 Dumper.indentation = 4;
12  
13 Dumper.prototype.dump = function(input, inline, indent, exceptionOnInvalidType, objectEncoder) {
14 var i, key, len, output, prefix, value, willBeInlined;
15 if (inline == null) {
16 inline = 0;
17 }
18 if (indent == null) {
19 indent = 0;
20 }
21 if (exceptionOnInvalidType == null) {
22 exceptionOnInvalidType = false;
23 }
24 if (objectEncoder == null) {
25 objectEncoder = null;
26 }
27 output = '';
28 prefix = (indent ? Utils.strRepeat(' ', indent) : '');
29 if (inline <= 0 || typeof input !== 'object' || input instanceof Date || Utils.isEmpty(input)) {
30 output += prefix + Inline.dump(input, exceptionOnInvalidType, objectEncoder);
31 } else {
32 if (input instanceof Array) {
33 for (i = 0, len = input.length; i < len; i++) {
34 value = input[i];
35 willBeInlined = inline - 1 <= 0 || typeof value !== 'object' || Utils.isEmpty(value);
36 output += prefix + '-' + (willBeInlined ? ' ' : "\n") + this.dump(value, inline - 1, (willBeInlined ? 0 : indent + this.indentation), exceptionOnInvalidType, objectEncoder) + (willBeInlined ? "\n" : '');
37 }
38 } else {
39 for (key in input) {
40 value = input[key];
41 willBeInlined = inline - 1 <= 0 || typeof value !== 'object' || Utils.isEmpty(value);
42 output += prefix + Inline.dump(key, exceptionOnInvalidType, objectEncoder) + ':' + (willBeInlined ? ' ' : "\n") + this.dump(value, inline - 1, (willBeInlined ? 0 : indent + this.indentation), exceptionOnInvalidType, objectEncoder) + (willBeInlined ? "\n" : '');
43 }
44 }
45 }
46 return output;
47 };
48  
49 return Dumper;
50  
51 })();
52  
53 module.exports = Dumper;
54  
55  
56 },{"./Inline":5,"./Utils":9}],2:[function(require,module,exports){
57 var Escaper, Pattern;
58  
59 Pattern = require('./Pattern');
60  
61 Escaper = (function() {
62 var ch;
63  
64 function Escaper() {}
65  
66 Escaper.LIST_ESCAPEES = ['\\', '\\\\', '\\"', '"', "\x00", "\x01", "\x02", "\x03", "\x04", "\x05", "\x06", "\x07", "\x08", "\x09", "\x0a", "\x0b", "\x0c", "\x0d", "\x0e", "\x0f", "\x10", "\x11", "\x12", "\x13", "\x14", "\x15", "\x16", "\x17", "\x18", "\x19", "\x1a", "\x1b", "\x1c", "\x1d", "\x1e", "\x1f", (ch = String.fromCharCode)(0x0085), ch(0x00A0), ch(0x2028), ch(0x2029)];
67  
68 Escaper.LIST_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"];
69  
70 Escaper.MAPPING_ESCAPEES_TO_ESCAPED = (function() {
71 var i, j, mapping, ref;
72 mapping = {};
73 for (i = j = 0, ref = Escaper.LIST_ESCAPEES.length; 0 <= ref ? j < ref : j > ref; i = 0 <= ref ? ++j : --j) {
74 mapping[Escaper.LIST_ESCAPEES[i]] = Escaper.LIST_ESCAPED[i];
75 }
76 return mapping;
77 })();
78  
79 Escaper.PATTERN_CHARACTERS_TO_ESCAPE = new Pattern('[\\x00-\\x1f]|\xc2\x85|\xc2\xa0|\xe2\x80\xa8|\xe2\x80\xa9');
80  
81 Escaper.PATTERN_MAPPING_ESCAPEES = new Pattern(Escaper.LIST_ESCAPEES.join('|').split('\\').join('\\\\'));
82  
83 Escaper.PATTERN_SINGLE_QUOTING = new Pattern('[\\s\'":{}[\\],&*#?]|^[-?|<>=!%@`]');
84  
85 Escaper.requiresDoubleQuoting = function(value) {
86 return this.PATTERN_CHARACTERS_TO_ESCAPE.test(value);
87 };
88  
89 Escaper.escapeWithDoubleQuotes = function(value) {
90 var result;
91 result = this.PATTERN_MAPPING_ESCAPEES.replace(value, (function(_this) {
92 return function(str) {
93 return _this.MAPPING_ESCAPEES_TO_ESCAPED[str];
94 };
95 })(this));
96 return '"' + result + '"';
97 };
98  
99 Escaper.requiresSingleQuoting = function(value) {
100 return this.PATTERN_SINGLE_QUOTING.test(value);
101 };
102  
103 Escaper.escapeWithSingleQuotes = function(value) {
104 return "'" + value.replace(/'/g, "''") + "'";
105 };
106  
107 return Escaper;
108  
109 })();
110  
111 module.exports = Escaper;
112  
113  
114 },{"./Pattern":7}],3:[function(require,module,exports){
115 var DumpException,
116 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; },
117 hasProp = {}.hasOwnProperty;
118  
119 DumpException = (function(superClass) {
120 extend(DumpException, superClass);
121  
122 function DumpException(message, parsedLine, snippet) {
123 this.message = message;
124 this.parsedLine = parsedLine;
125 this.snippet = snippet;
126 }
127  
128 DumpException.prototype.toString = function() {
129 if ((this.parsedLine != null) && (this.snippet != null)) {
130 return '<DumpException> ' + this.message + ' (line ' + this.parsedLine + ': \'' + this.snippet + '\')';
131 } else {
132 return '<DumpException> ' + this.message;
133 }
134 };
135  
136 return DumpException;
137  
138 })(Error);
139  
140 module.exports = DumpException;
141  
142  
143 },{}],4:[function(require,module,exports){
144 var ParseException,
145 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; },
146 hasProp = {}.hasOwnProperty;
147  
148 ParseException = (function(superClass) {
149 extend(ParseException, superClass);
150  
151 function ParseException(message, parsedLine, snippet) {
152 this.message = message;
153 this.parsedLine = parsedLine;
154 this.snippet = snippet;
155 }
156  
157 ParseException.prototype.toString = function() {
158 if ((this.parsedLine != null) && (this.snippet != null)) {
159 return '<ParseException> ' + this.message + ' (line ' + this.parsedLine + ': \'' + this.snippet + '\')';
160 } else {
161 return '<ParseException> ' + this.message;
162 }
163 };
164  
165 return ParseException;
166  
167 })(Error);
168  
169 module.exports = ParseException;
170  
171  
172 },{}],5:[function(require,module,exports){
173 var DumpException, Escaper, Inline, ParseException, Pattern, Unescaper, Utils,
174 indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
175  
176 Pattern = require('./Pattern');
177  
178 Unescaper = require('./Unescaper');
179  
180 Escaper = require('./Escaper');
181  
182 Utils = require('./Utils');
183  
184 ParseException = require('./Exception/ParseException');
185  
186 DumpException = require('./Exception/DumpException');
187  
188 Inline = (function() {
189 function Inline() {}
190  
191 Inline.REGEX_QUOTED_STRING = '(?:"(?:[^"\\\\]*(?:\\\\.[^"\\\\]*)*)"|\'(?:[^\']*(?:\'\'[^\']*)*)\')';
192  
193 Inline.PATTERN_TRAILING_COMMENTS = new Pattern('^\\s*#.*$');
194  
195 Inline.PATTERN_QUOTED_SCALAR = new Pattern('^' + Inline.REGEX_QUOTED_STRING);
196  
197 Inline.PATTERN_THOUSAND_NUMERIC_SCALAR = new Pattern('^(-|\\+)?[0-9,]+(\\.[0-9]+)?$');
198  
199 Inline.PATTERN_SCALAR_BY_DELIMITERS = {};
200  
201 Inline.settings = {};
202  
203 Inline.configure = function(exceptionOnInvalidType, objectDecoder) {
204 if (exceptionOnInvalidType == null) {
205 exceptionOnInvalidType = null;
206 }
207 if (objectDecoder == null) {
208 objectDecoder = null;
209 }
210 this.settings.exceptionOnInvalidType = exceptionOnInvalidType;
211 this.settings.objectDecoder = objectDecoder;
212 };
213  
214 Inline.parse = function(value, exceptionOnInvalidType, objectDecoder) {
215 var context, result;
216 if (exceptionOnInvalidType == null) {
217 exceptionOnInvalidType = false;
218 }
219 if (objectDecoder == null) {
220 objectDecoder = null;
221 }
222 this.settings.exceptionOnInvalidType = exceptionOnInvalidType;
223 this.settings.objectDecoder = objectDecoder;
224 if (value == null) {
225 return '';
226 }
227 value = Utils.trim(value);
228 if (0 === value.length) {
229 return '';
230 }
231 context = {
232 exceptionOnInvalidType: exceptionOnInvalidType,
233 objectDecoder: objectDecoder,
234 i: 0
235 };
236 switch (value.charAt(0)) {
237 case '[':
238 result = this.parseSequence(value, context);
239 ++context.i;
240 break;
241 case '{':
242 result = this.parseMapping(value, context);
243 ++context.i;
244 break;
245 default:
246 result = this.parseScalar(value, null, ['"', "'"], context);
247 }
248 if (this.PATTERN_TRAILING_COMMENTS.replace(value.slice(context.i), '') !== '') {
249 throw new ParseException('Unexpected characters near "' + value.slice(context.i) + '".');
250 }
251 return result;
252 };
253  
254 Inline.dump = function(value, exceptionOnInvalidType, objectEncoder) {
255 var ref, result, type;
256 if (exceptionOnInvalidType == null) {
257 exceptionOnInvalidType = false;
258 }
259 if (objectEncoder == null) {
260 objectEncoder = null;
261 }
262 if (value == null) {
263 return 'null';
264 }
265 type = typeof value;
266 if (type === 'object') {
267 if (value instanceof Date) {
268 return value.toISOString();
269 } else if (objectEncoder != null) {
270 result = objectEncoder(value);
271 if (typeof result === 'string' || (result != null)) {
272 return result;
273 }
274 }
275 return this.dumpObject(value);
276 }
277 if (type === 'boolean') {
278 return (value ? 'true' : 'false');
279 }
280 if (Utils.isDigits(value)) {
281 return (type === 'string' ? "'" + value + "'" : String(parseInt(value)));
282 }
283 if (Utils.isNumeric(value)) {
284 return (type === 'string' ? "'" + value + "'" : String(parseFloat(value)));
285 }
286 if (type === 'number') {
287 return (value === Infinity ? '.Inf' : (value === -Infinity ? '-.Inf' : (isNaN(value) ? '.NaN' : value)));
288 }
289 if (Escaper.requiresDoubleQuoting(value)) {
290 return Escaper.escapeWithDoubleQuotes(value);
291 }
292 if (Escaper.requiresSingleQuoting(value)) {
293 return Escaper.escapeWithSingleQuotes(value);
294 }
295 if ('' === value) {
296 return '""';
297 }
298 if (Utils.PATTERN_DATE.test(value)) {
299 return "'" + value + "'";
300 }
301 if ((ref = value.toLowerCase()) === 'null' || ref === '~' || ref === 'true' || ref === 'false') {
302 return "'" + value + "'";
303 }
304 return value;
305 };
306  
307 Inline.dumpObject = function(value, exceptionOnInvalidType, objectSupport) {
308 var j, key, len1, output, val;
309 if (objectSupport == null) {
310 objectSupport = null;
311 }
312 if (value instanceof Array) {
313 output = [];
314 for (j = 0, len1 = value.length; j < len1; j++) {
315 val = value[j];
316 output.push(this.dump(val));
317 }
318 return '[' + output.join(', ') + ']';
319 } else {
320 output = [];
321 for (key in value) {
322 val = value[key];
323 output.push(this.dump(key) + ': ' + this.dump(val));
324 }
325 return '{' + output.join(', ') + '}';
326 }
327 };
328  
329 Inline.parseScalar = function(scalar, delimiters, stringDelimiters, context, evaluate) {
330 var i, joinedDelimiters, match, output, pattern, ref, ref1, strpos, tmp;
331 if (delimiters == null) {
332 delimiters = null;
333 }
334 if (stringDelimiters == null) {
335 stringDelimiters = ['"', "'"];
336 }
337 if (context == null) {
338 context = null;
339 }
340 if (evaluate == null) {
341 evaluate = true;
342 }
343 if (context == null) {
344 context = {
345 exceptionOnInvalidType: this.settings.exceptionOnInvalidType,
346 objectDecoder: this.settings.objectDecoder,
347 i: 0
348 };
349 }
350 i = context.i;
351 if (ref = scalar.charAt(i), indexOf.call(stringDelimiters, ref) >= 0) {
352 output = this.parseQuotedScalar(scalar, context);
353 i = context.i;
354 if (delimiters != null) {
355 tmp = Utils.ltrim(scalar.slice(i), ' ');
356 if (!(ref1 = tmp.charAt(0), indexOf.call(delimiters, ref1) >= 0)) {
357 throw new ParseException('Unexpected characters (' + scalar.slice(i) + ').');
358 }
359 }
360 } else {
361 if (!delimiters) {
362 output = scalar.slice(i);
363 i += output.length;
364 strpos = output.indexOf(' #');
365 if (strpos !== -1) {
366 output = Utils.rtrim(output.slice(0, strpos));
367 }
368 } else {
369 joinedDelimiters = delimiters.join('|');
370 pattern = this.PATTERN_SCALAR_BY_DELIMITERS[joinedDelimiters];
371 if (pattern == null) {
372 pattern = new Pattern('^(.+?)(' + joinedDelimiters + ')');
373 this.PATTERN_SCALAR_BY_DELIMITERS[joinedDelimiters] = pattern;
374 }
375 if (match = pattern.exec(scalar.slice(i))) {
376 output = match[1];
377 i += output.length;
378 } else {
379 throw new ParseException('Malformed inline YAML string (' + scalar + ').');
380 }
381 }
382 if (evaluate) {
383 output = this.evaluateScalar(output, context);
384 }
385 }
386 context.i = i;
387 return output;
388 };
389  
390 Inline.parseQuotedScalar = function(scalar, context) {
391 var i, match, output;
392 i = context.i;
393 if (!(match = this.PATTERN_QUOTED_SCALAR.exec(scalar.slice(i)))) {
394 throw new ParseException('Malformed inline YAML string (' + scalar.slice(i) + ').');
395 }
396 output = match[0].substr(1, match[0].length - 2);
397 if ('"' === scalar.charAt(i)) {
398 output = Unescaper.unescapeDoubleQuotedString(output);
399 } else {
400 output = Unescaper.unescapeSingleQuotedString(output);
401 }
402 i += match[0].length;
403 context.i = i;
404 return output;
405 };
406  
407 Inline.parseSequence = function(sequence, context) {
408 var e, error, i, isQuoted, len, output, ref, value;
409 output = [];
410 len = sequence.length;
411 i = context.i;
412 i += 1;
413 while (i < len) {
414 context.i = i;
415 switch (sequence.charAt(i)) {
416 case '[':
417 output.push(this.parseSequence(sequence, context));
418 i = context.i;
419 break;
420 case '{':
421 output.push(this.parseMapping(sequence, context));
422 i = context.i;
423 break;
424 case ']':
425 return output;
426 case ',':
427 case ' ':
428 case "\n":
429 break;
430 default:
431 isQuoted = ((ref = sequence.charAt(i)) === '"' || ref === "'");
432 value = this.parseScalar(sequence, [',', ']'], ['"', "'"], context);
433 i = context.i;
434 if (!isQuoted && typeof value === 'string' && (value.indexOf(': ') !== -1 || value.indexOf(":\n") !== -1)) {
435 try {
436 value = this.parseMapping('{' + value + '}');
437 } catch (error) {
438 e = error;
439 }
440 }
441 output.push(value);
442 --i;
443 }
444 ++i;
445 }
446 throw new ParseException('Malformed inline YAML string ' + sequence);
447 };
448  
449 Inline.parseMapping = function(mapping, context) {
450 var done, i, key, len, output, shouldContinueWhileLoop, value;
451 output = {};
452 len = mapping.length;
453 i = context.i;
454 i += 1;
455 shouldContinueWhileLoop = false;
456 while (i < len) {
457 context.i = i;
458 switch (mapping.charAt(i)) {
459 case ' ':
460 case ',':
461 case "\n":
462 ++i;
463 context.i = i;
464 shouldContinueWhileLoop = true;
465 break;
466 case '}':
467 return output;
468 }
469 if (shouldContinueWhileLoop) {
470 shouldContinueWhileLoop = false;
471 continue;
472 }
473 key = this.parseScalar(mapping, [':', ' ', "\n"], ['"', "'"], context, false);
474 i = context.i;
475 done = false;
476 while (i < len) {
477 context.i = i;
478 switch (mapping.charAt(i)) {
479 case '[':
480 value = this.parseSequence(mapping, context);
481 i = context.i;
482 if (output[key] === void 0) {
483 output[key] = value;
484 }
485 done = true;
486 break;
487 case '{':
488 value = this.parseMapping(mapping, context);
489 i = context.i;
490 if (output[key] === void 0) {
491 output[key] = value;
492 }
493 done = true;
494 break;
495 case ':':
496 case ' ':
497 case "\n":
498 break;
499 default:
500 value = this.parseScalar(mapping, [',', '}'], ['"', "'"], context);
501 i = context.i;
502 if (output[key] === void 0) {
503 output[key] = value;
504 }
505 done = true;
506 --i;
507 }
508 ++i;
509 if (done) {
510 break;
511 }
512 }
513 }
514 throw new ParseException('Malformed inline YAML string ' + mapping);
515 };
516  
517 Inline.evaluateScalar = function(scalar, context) {
518 var cast, date, exceptionOnInvalidType, firstChar, firstSpace, firstWord, objectDecoder, raw, scalarLower, subValue, trimmedScalar;
519 scalar = Utils.trim(scalar);
520 scalarLower = scalar.toLowerCase();
521 switch (scalarLower) {
522 case 'null':
523 case '':
524 case '~':
525 return null;
526 case 'true':
527 return true;
528 case 'false':
529 return false;
530 case '.inf':
531 return Infinity;
532 case '.nan':
533 return NaN;
534 case '-.inf':
535 return Infinity;
536 default:
537 firstChar = scalarLower.charAt(0);
538 switch (firstChar) {
539 case '!':
540 firstSpace = scalar.indexOf(' ');
541 if (firstSpace === -1) {
542 firstWord = scalarLower;
543 } else {
544 firstWord = scalarLower.slice(0, firstSpace);
545 }
546 switch (firstWord) {
547 case '!':
548 if (firstSpace !== -1) {
549 return parseInt(this.parseScalar(scalar.slice(2)));
550 }
551 return null;
552 case '!str':
553 return Utils.ltrim(scalar.slice(4));
554 case '!!str':
555 return Utils.ltrim(scalar.slice(5));
556 case '!!int':
557 return parseInt(this.parseScalar(scalar.slice(5)));
558 case '!!bool':
559 return Utils.parseBoolean(this.parseScalar(scalar.slice(6)), false);
560 case '!!float':
561 return parseFloat(this.parseScalar(scalar.slice(7)));
562 case '!!timestamp':
563 return Utils.stringToDate(Utils.ltrim(scalar.slice(11)));
564 default:
565 if (context == null) {
566 context = {
567 exceptionOnInvalidType: this.settings.exceptionOnInvalidType,
568 objectDecoder: this.settings.objectDecoder,
569 i: 0
570 };
571 }
572 objectDecoder = context.objectDecoder, exceptionOnInvalidType = context.exceptionOnInvalidType;
573 if (objectDecoder) {
574 trimmedScalar = Utils.rtrim(scalar);
575 firstSpace = trimmedScalar.indexOf(' ');
576 if (firstSpace === -1) {
577 return objectDecoder(trimmedScalar, null);
578 } else {
579 subValue = Utils.ltrim(trimmedScalar.slice(firstSpace + 1));
580 if (!(subValue.length > 0)) {
581 subValue = null;
582 }
583 return objectDecoder(trimmedScalar.slice(0, firstSpace), subValue);
584 }
585 }
586 if (exceptionOnInvalidType) {
587 throw new ParseException('Custom object support when parsing a YAML file has been disabled.');
588 }
589 return null;
590 }
591 break;
592 case '0':
593 if ('0x' === scalar.slice(0, 2)) {
594 return Utils.hexDec(scalar);
595 } else if (Utils.isDigits(scalar)) {
596 return Utils.octDec(scalar);
597 } else if (Utils.isNumeric(scalar)) {
598 return parseFloat(scalar);
599 } else {
600 return scalar;
601 }
602 break;
603 case '+':
604 if (Utils.isDigits(scalar)) {
605 raw = scalar;
606 cast = parseInt(raw);
607 if (raw === String(cast)) {
608 return cast;
609 } else {
610 return raw;
611 }
612 } else if (Utils.isNumeric(scalar)) {
613 return parseFloat(scalar);
614 } else if (this.PATTERN_THOUSAND_NUMERIC_SCALAR.test(scalar)) {
615 return parseFloat(scalar.replace(',', ''));
616 }
617 return scalar;
618 case '-':
619 if (Utils.isDigits(scalar.slice(1))) {
620 if ('0' === scalar.charAt(1)) {
621 return -Utils.octDec(scalar.slice(1));
622 } else {
623 raw = scalar.slice(1);
624 cast = parseInt(raw);
625 if (raw === String(cast)) {
626 return -cast;
627 } else {
628 return -raw;
629 }
630 }
631 } else if (Utils.isNumeric(scalar)) {
632 return parseFloat(scalar);
633 } else if (this.PATTERN_THOUSAND_NUMERIC_SCALAR.test(scalar)) {
634 return parseFloat(scalar.replace(',', ''));
635 }
636 return scalar;
637 default:
638 if (date = Utils.stringToDate(scalar)) {
639 return date;
640 } else if (Utils.isNumeric(scalar)) {
641 return parseFloat(scalar);
642 } else if (this.PATTERN_THOUSAND_NUMERIC_SCALAR.test(scalar)) {
643 return parseFloat(scalar.replace(',', ''));
644 }
645 return scalar;
646 }
647 }
648 };
649  
650 return Inline;
651  
652 })();
653  
654 module.exports = Inline;
655  
656  
657 },{"./Escaper":2,"./Exception/DumpException":3,"./Exception/ParseException":4,"./Pattern":7,"./Unescaper":8,"./Utils":9}],6:[function(require,module,exports){
658 var Inline, ParseException, Parser, Pattern, Utils;
659  
660 Inline = require('./Inline');
661  
662 Pattern = require('./Pattern');
663  
664 Utils = require('./Utils');
665  
666 ParseException = require('./Exception/ParseException');
667  
668 Parser = (function() {
669 Parser.prototype.PATTERN_FOLDED_SCALAR_ALL = new Pattern('^(?:(?<type>![^\\|>]*)\\s+)?(?<separator>\\||>)(?<modifiers>\\+|\\-|\\d+|\\+\\d+|\\-\\d+|\\d+\\+|\\d+\\-)?(?<comments> +#.*)?$');
670  
671 Parser.prototype.PATTERN_FOLDED_SCALAR_END = new Pattern('(?<separator>\\||>)(?<modifiers>\\+|\\-|\\d+|\\+\\d+|\\-\\d+|\\d+\\+|\\d+\\-)?(?<comments> +#.*)?$');
672  
673 Parser.prototype.PATTERN_SEQUENCE_ITEM = new Pattern('^\\-((?<leadspaces>\\s+)(?<value>.+?))?\\s*$');
674  
675 Parser.prototype.PATTERN_ANCHOR_VALUE = new Pattern('^&(?<ref>[^ ]+) *(?<value>.*)');
676  
677 Parser.prototype.PATTERN_COMPACT_NOTATION = new Pattern('^(?<key>' + Inline.REGEX_QUOTED_STRING + '|[^ \'"\\{\\[].*?) *\\:(\\s+(?<value>.+?))?\\s*$');
678  
679 Parser.prototype.PATTERN_MAPPING_ITEM = new Pattern('^(?<key>' + Inline.REGEX_QUOTED_STRING + '|[^ \'"\\[\\{].*?) *\\:(\\s+(?<value>.+?))?\\s*$');
680  
681 Parser.prototype.PATTERN_DECIMAL = new Pattern('\\d+');
682  
683 Parser.prototype.PATTERN_INDENT_SPACES = new Pattern('^ +');
684  
685 Parser.prototype.PATTERN_TRAILING_LINES = new Pattern('(\n*)$');
686  
687 Parser.prototype.PATTERN_YAML_HEADER = new Pattern('^\\%YAML[: ][\\d\\.]+.*\n');
688  
689 Parser.prototype.PATTERN_LEADING_COMMENTS = new Pattern('^(\\#.*?\n)+');
690  
691 Parser.prototype.PATTERN_DOCUMENT_MARKER_START = new Pattern('^\\-\\-\\-.*?\n');
692  
693 Parser.prototype.PATTERN_DOCUMENT_MARKER_END = new Pattern('^\\.\\.\\.\\s*$');
694  
695 Parser.prototype.PATTERN_FOLDED_SCALAR_BY_INDENTATION = {};
696  
697 Parser.prototype.CONTEXT_NONE = 0;
698  
699 Parser.prototype.CONTEXT_SEQUENCE = 1;
700  
701 Parser.prototype.CONTEXT_MAPPING = 2;
702  
703 function Parser(offset) {
704 this.offset = offset != null ? offset : 0;
705 this.lines = [];
706 this.currentLineNb = -1;
707 this.currentLine = '';
708 this.refs = {};
709 }
710  
711 Parser.prototype.parse = function(value, exceptionOnInvalidType, objectDecoder) {
712 var alias, allowOverwrite, block, c, context, data, e, error, error1, error2, first, i, indent, isRef, j, k, key, l, lastKey, len, len1, len2, len3, lineCount, m, matches, mergeNode, n, name, parsed, parsedItem, parser, ref, ref1, ref2, refName, refValue, val, values;
713 if (exceptionOnInvalidType == null) {
714 exceptionOnInvalidType = false;
715 }
716 if (objectDecoder == null) {
717 objectDecoder = null;
718 }
719 this.currentLineNb = -1;
720 this.currentLine = '';
721 this.lines = this.cleanup(value).split("\n");
722 data = null;
723 context = this.CONTEXT_NONE;
724 allowOverwrite = false;
725 while (this.moveToNextLine()) {
726 if (this.isCurrentLineEmpty()) {
727 continue;
728 }
729 if ("\t" === this.currentLine[0]) {
730 throw new ParseException('A YAML file cannot contain tabs as indentation.', this.getRealCurrentLineNb() + 1, this.currentLine);
731 }
732 isRef = mergeNode = false;
733 if (values = this.PATTERN_SEQUENCE_ITEM.exec(this.currentLine)) {
734 if (this.CONTEXT_MAPPING === context) {
735 throw new ParseException('You cannot define a sequence item when in a mapping');
736 }
737 context = this.CONTEXT_SEQUENCE;
738 if (data == null) {
739 data = [];
740 }
741 if ((values.value != null) && (matches = this.PATTERN_ANCHOR_VALUE.exec(values.value))) {
742 isRef = matches.ref;
743 values.value = matches.value;
744 }
745 if (!(values.value != null) || '' === Utils.trim(values.value, ' ') || Utils.ltrim(values.value, ' ').indexOf('#') === 0) {
746 if (this.currentLineNb < this.lines.length - 1 && !this.isNextLineUnIndentedCollection()) {
747 c = this.getRealCurrentLineNb() + 1;
748 parser = new Parser(c);
749 parser.refs = this.refs;
750 data.push(parser.parse(this.getNextEmbedBlock(null, true), exceptionOnInvalidType, objectDecoder));
751 } else {
752 data.push(null);
753 }
754 } else {
755 if (((ref = values.leadspaces) != null ? ref.length : void 0) && (matches = this.PATTERN_COMPACT_NOTATION.exec(values.value))) {
756 c = this.getRealCurrentLineNb();
757 parser = new Parser(c);
758 parser.refs = this.refs;
759 block = values.value;
760 indent = this.getCurrentLineIndentation();
761 if (this.isNextLineIndented(false)) {
762 block += "\n" + this.getNextEmbedBlock(indent + values.leadspaces.length + 1, true);
763 }
764 data.push(parser.parse(block, exceptionOnInvalidType, objectDecoder));
765 } else {
766 data.push(this.parseValue(values.value, exceptionOnInvalidType, objectDecoder));
767 }
768 }
769 } else if ((values = this.PATTERN_MAPPING_ITEM.exec(this.currentLine)) && values.key.indexOf(' #') === -1) {
770 if (this.CONTEXT_SEQUENCE === context) {
771 throw new ParseException('You cannot define a mapping item when in a sequence');
772 }
773 context = this.CONTEXT_MAPPING;
774 if (data == null) {
775 data = {};
776 }
777 Inline.configure(exceptionOnInvalidType, objectDecoder);
778 try {
779 key = Inline.parseScalar(values.key);
780 } catch (error) {
781 e = error;
782 e.parsedLine = this.getRealCurrentLineNb() + 1;
783 e.snippet = this.currentLine;
784 throw e;
785 }
786 if ('<<' === key) {
787 mergeNode = true;
788 allowOverwrite = true;
789 if (((ref1 = values.value) != null ? ref1.indexOf('*') : void 0) === 0) {
790 refName = values.value.slice(1);
791 if (this.refs[refName] == null) {
792 throw new ParseException('Reference "' + refName + '" does not exist.', this.getRealCurrentLineNb() + 1, this.currentLine);
793 }
794 refValue = this.refs[refName];
795 if (typeof refValue !== 'object') {
796 throw new ParseException('YAML merge keys used with a scalar value instead of an object.', this.getRealCurrentLineNb() + 1, this.currentLine);
797 }
798 if (refValue instanceof Array) {
799 for (i = j = 0, len = refValue.length; j < len; i = ++j) {
800 value = refValue[i];
801 if (data[name = String(i)] == null) {
802 data[name] = value;
803 }
804 }
805 } else {
806 for (key in refValue) {
807 value = refValue[key];
808 if (data[key] == null) {
809 data[key] = value;
810 }
811 }
812 }
813 } else {
814 if ((values.value != null) && values.value !== '') {
815 value = values.value;
816 } else {
817 value = this.getNextEmbedBlock();
818 }
819 c = this.getRealCurrentLineNb() + 1;
820 parser = new Parser(c);
821 parser.refs = this.refs;
822 parsed = parser.parse(value, exceptionOnInvalidType);
823 if (typeof parsed !== 'object') {
824 throw new ParseException('YAML merge keys used with a scalar value instead of an object.', this.getRealCurrentLineNb() + 1, this.currentLine);
825 }
826 if (parsed instanceof Array) {
827 for (l = 0, len1 = parsed.length; l < len1; l++) {
828 parsedItem = parsed[l];
829 if (typeof parsedItem !== 'object') {
830 throw new ParseException('Merge items must be objects.', this.getRealCurrentLineNb() + 1, parsedItem);
831 }
832 if (parsedItem instanceof Array) {
833 for (i = m = 0, len2 = parsedItem.length; m < len2; i = ++m) {
834 value = parsedItem[i];
835 k = String(i);
836 if (!data.hasOwnProperty(k)) {
837 data[k] = value;
838 }
839 }
840 } else {
841 for (key in parsedItem) {
842 value = parsedItem[key];
843 if (!data.hasOwnProperty(key)) {
844 data[key] = value;
845 }
846 }
847 }
848 }
849 } else {
850 for (key in parsed) {
851 value = parsed[key];
852 if (!data.hasOwnProperty(key)) {
853 data[key] = value;
854 }
855 }
856 }
857 }
858 } else if ((values.value != null) && (matches = this.PATTERN_ANCHOR_VALUE.exec(values.value))) {
859 isRef = matches.ref;
860 values.value = matches.value;
861 }
862 if (mergeNode) {
863  
864 } else if (!(values.value != null) || '' === Utils.trim(values.value, ' ') || Utils.ltrim(values.value, ' ').indexOf('#') === 0) {
865 if (!(this.isNextLineIndented()) && !(this.isNextLineUnIndentedCollection())) {
866 if (allowOverwrite || data[key] === void 0) {
867 data[key] = null;
868 }
869 } else {
870 c = this.getRealCurrentLineNb() + 1;
871 parser = new Parser(c);
872 parser.refs = this.refs;
873 val = parser.parse(this.getNextEmbedBlock(), exceptionOnInvalidType, objectDecoder);
874 if (allowOverwrite || data[key] === void 0) {
875 data[key] = val;
876 }
877 }
878 } else {
879 val = this.parseValue(values.value, exceptionOnInvalidType, objectDecoder);
880 if (allowOverwrite || data[key] === void 0) {
881 data[key] = val;
882 }
883 }
884 } else {
885 lineCount = this.lines.length;
886 if (1 === lineCount || (2 === lineCount && Utils.isEmpty(this.lines[1]))) {
887 try {
888 value = Inline.parse(this.lines[0], exceptionOnInvalidType, objectDecoder);
889 } catch (error1) {
890 e = error1;
891 e.parsedLine = this.getRealCurrentLineNb() + 1;
892 e.snippet = this.currentLine;
893 throw e;
894 }
895 if (typeof value === 'object') {
896 if (value instanceof Array) {
897 first = value[0];
898 } else {
899 for (key in value) {
900 first = value[key];
901 break;
902 }
903 }
904 if (typeof first === 'string' && first.indexOf('*') === 0) {
905 data = [];
906 for (n = 0, len3 = value.length; n < len3; n++) {
907 alias = value[n];
908 data.push(this.refs[alias.slice(1)]);
909 }
910 value = data;
911 }
912 }
913 return value;
914 } else if ((ref2 = Utils.ltrim(value).charAt(0)) === '[' || ref2 === '{') {
915 try {
916 return Inline.parse(value, exceptionOnInvalidType, objectDecoder);
917 } catch (error2) {
918 e = error2;
919 e.parsedLine = this.getRealCurrentLineNb() + 1;
920 e.snippet = this.currentLine;
921 throw e;
922 }
923 }
924 throw new ParseException('Unable to parse.', this.getRealCurrentLineNb() + 1, this.currentLine);
925 }
926 if (isRef) {
927 if (data instanceof Array) {
928 this.refs[isRef] = data[data.length - 1];
929 } else {
930 lastKey = null;
931 for (key in data) {
932 lastKey = key;
933 }
934 this.refs[isRef] = data[lastKey];
935 }
936 }
937 }
938 if (Utils.isEmpty(data)) {
939 return null;
940 } else {
941 return data;
942 }
943 };
944  
945 Parser.prototype.getRealCurrentLineNb = function() {
946 return this.currentLineNb + this.offset;
947 };
948  
949 Parser.prototype.getCurrentLineIndentation = function() {
950 return this.currentLine.length - Utils.ltrim(this.currentLine, ' ').length;
951 };
952  
953 Parser.prototype.getNextEmbedBlock = function(indentation, includeUnindentedCollection) {
954 var data, indent, isItUnindentedCollection, newIndent, removeComments, removeCommentsPattern, unindentedEmbedBlock;
955 if (indentation == null) {
956 indentation = null;
957 }
958 if (includeUnindentedCollection == null) {
959 includeUnindentedCollection = false;
960 }
961 this.moveToNextLine();
962 if (indentation == null) {
963 newIndent = this.getCurrentLineIndentation();
964 unindentedEmbedBlock = this.isStringUnIndentedCollectionItem(this.currentLine);
965 if (!(this.isCurrentLineEmpty()) && 0 === newIndent && !unindentedEmbedBlock) {
966 throw new ParseException('Indentation problem.', this.getRealCurrentLineNb() + 1, this.currentLine);
967 }
968 } else {
969 newIndent = indentation;
970 }
971 data = [this.currentLine.slice(newIndent)];
972 if (!includeUnindentedCollection) {
973 isItUnindentedCollection = this.isStringUnIndentedCollectionItem(this.currentLine);
974 }
975 removeCommentsPattern = this.PATTERN_FOLDED_SCALAR_END;
976 removeComments = !removeCommentsPattern.test(this.currentLine);
977 while (this.moveToNextLine()) {
978 indent = this.getCurrentLineIndentation();
979 if (indent === newIndent) {
980 removeComments = !removeCommentsPattern.test(this.currentLine);
981 }
982 if (isItUnindentedCollection && !this.isStringUnIndentedCollectionItem(this.currentLine) && indent === newIndent) {
983 this.moveToPreviousLine();
984 break;
985 }
986 if (this.isCurrentLineBlank()) {
987 data.push(this.currentLine.slice(newIndent));
988 continue;
989 }
990 if (removeComments && this.isCurrentLineComment()) {
991 if (indent === newIndent) {
992 continue;
993 }
994 }
995 if (indent >= newIndent) {
996 data.push(this.currentLine.slice(newIndent));
997 } else if (Utils.ltrim(this.currentLine).charAt(0) === '#') {
998  
999 } else if (0 === indent) {
1000 this.moveToPreviousLine();
1001 break;
1002 } else {
1003 throw new ParseException('Indentation problem.', this.getRealCurrentLineNb() + 1, this.currentLine);
1004 }
1005 }
1006 return data.join("\n");
1007 };
1008  
1009 Parser.prototype.moveToNextLine = function() {
1010 if (this.currentLineNb >= this.lines.length - 1) {
1011 return false;
1012 }
1013 this.currentLine = this.lines[++this.currentLineNb];
1014 return true;
1015 };
1016  
1017 Parser.prototype.moveToPreviousLine = function() {
1018 this.currentLine = this.lines[--this.currentLineNb];
1019 };
1020  
1021 Parser.prototype.parseValue = function(value, exceptionOnInvalidType, objectDecoder) {
1022 var e, error, error1, foldedIndent, matches, modifiers, pos, ref, ref1, val;
1023 if (0 === value.indexOf('*')) {
1024 pos = value.indexOf('#');
1025 if (pos !== -1) {
1026 value = value.substr(1, pos - 2);
1027 } else {
1028 value = value.slice(1);
1029 }
1030 if (this.refs[value] === void 0) {
1031 throw new ParseException('Reference "' + value + '" does not exist.', this.currentLine);
1032 }
1033 return this.refs[value];
1034 }
1035 if (matches = this.PATTERN_FOLDED_SCALAR_ALL.exec(value)) {
1036 modifiers = (ref = matches.modifiers) != null ? ref : '';
1037 foldedIndent = Math.abs(parseInt(modifiers));
1038 if (isNaN(foldedIndent)) {
1039 foldedIndent = 0;
1040 }
1041 val = this.parseFoldedScalar(matches.separator, this.PATTERN_DECIMAL.replace(modifiers, ''), foldedIndent);
1042 if (matches.type != null) {
1043 Inline.configure(exceptionOnInvalidType, objectDecoder);
1044 return Inline.parseScalar(matches.type + ' ' + val);
1045 } else {
1046 return val;
1047 }
1048 }
1049 try {
1050 return Inline.parse(value, exceptionOnInvalidType, objectDecoder);
1051 } catch (error) {
1052 e = error;
1053 if (((ref1 = value.charAt(0)) === '[' || ref1 === '{') && e instanceof ParseException && this.isNextLineIndented()) {
1054 value += "\n" + this.getNextEmbedBlock();
1055 try {
1056 return Inline.parse(value, exceptionOnInvalidType, objectDecoder);
1057 } catch (error1) {
1058 e = error1;
1059 e.parsedLine = this.getRealCurrentLineNb() + 1;
1060 e.snippet = this.currentLine;
1061 throw e;
1062 }
1063 } else {
1064 e.parsedLine = this.getRealCurrentLineNb() + 1;
1065 e.snippet = this.currentLine;
1066 throw e;
1067 }
1068 }
1069 };
1070  
1071 Parser.prototype.parseFoldedScalar = function(separator, indicator, indentation) {
1072 var isCurrentLineBlank, j, len, line, matches, newText, notEOF, pattern, ref, text;
1073 if (indicator == null) {
1074 indicator = '';
1075 }
1076 if (indentation == null) {
1077 indentation = 0;
1078 }
1079 notEOF = this.moveToNextLine();
1080 if (!notEOF) {
1081 return '';
1082 }
1083 isCurrentLineBlank = this.isCurrentLineBlank();
1084 text = '';
1085 while (notEOF && isCurrentLineBlank) {
1086 if (notEOF = this.moveToNextLine()) {
1087 text += "\n";
1088 isCurrentLineBlank = this.isCurrentLineBlank();
1089 }
1090 }
1091 if (0 === indentation) {
1092 if (matches = this.PATTERN_INDENT_SPACES.exec(this.currentLine)) {
1093 indentation = matches[0].length;
1094 }
1095 }
1096 if (indentation > 0) {
1097 pattern = this.PATTERN_FOLDED_SCALAR_BY_INDENTATION[indentation];
1098 if (pattern == null) {
1099 pattern = new Pattern('^ {' + indentation + '}(.*)$');
1100 Parser.prototype.PATTERN_FOLDED_SCALAR_BY_INDENTATION[indentation] = pattern;
1101 }
1102 while (notEOF && (isCurrentLineBlank || (matches = pattern.exec(this.currentLine)))) {
1103 if (isCurrentLineBlank) {
1104 text += this.currentLine.slice(indentation);
1105 } else {
1106 text += matches[1];
1107 }
1108 if (notEOF = this.moveToNextLine()) {
1109 text += "\n";
1110 isCurrentLineBlank = this.isCurrentLineBlank();
1111 }
1112 }
1113 } else if (notEOF) {
1114 text += "\n";
1115 }
1116 if (notEOF) {
1117 this.moveToPreviousLine();
1118 }
1119 if ('>' === separator) {
1120 newText = '';
1121 ref = text.split("\n");
1122 for (j = 0, len = ref.length; j < len; j++) {
1123 line = ref[j];
1124 if (line.length === 0 || line.charAt(0) === ' ') {
1125 newText = Utils.rtrim(newText, ' ') + line + "\n";
1126 } else {
1127 newText += line + ' ';
1128 }
1129 }
1130 text = newText;
1131 }
1132 if ('+' !== indicator) {
1133 text = Utils.rtrim(text);
1134 }
1135 if ('' === indicator) {
1136 text = this.PATTERN_TRAILING_LINES.replace(text, "\n");
1137 } else if ('-' === indicator) {
1138 text = this.PATTERN_TRAILING_LINES.replace(text, '');
1139 }
1140 return text;
1141 };
1142  
1143 Parser.prototype.isNextLineIndented = function(ignoreComments) {
1144 var EOF, currentIndentation, ret;
1145 if (ignoreComments == null) {
1146 ignoreComments = true;
1147 }
1148 currentIndentation = this.getCurrentLineIndentation();
1149 EOF = !this.moveToNextLine();
1150 if (ignoreComments) {
1151 while (!EOF && this.isCurrentLineEmpty()) {
1152 EOF = !this.moveToNextLine();
1153 }
1154 } else {
1155 while (!EOF && this.isCurrentLineBlank()) {
1156 EOF = !this.moveToNextLine();
1157 }
1158 }
1159 if (EOF) {
1160 return false;
1161 }
1162 ret = false;
1163 if (this.getCurrentLineIndentation() > currentIndentation) {
1164 ret = true;
1165 }
1166 this.moveToPreviousLine();
1167 return ret;
1168 };
1169  
1170 Parser.prototype.isCurrentLineEmpty = function() {
1171 var trimmedLine;
1172 trimmedLine = Utils.trim(this.currentLine, ' ');
1173 return trimmedLine.length === 0 || trimmedLine.charAt(0) === '#';
1174 };
1175  
1176 Parser.prototype.isCurrentLineBlank = function() {
1177 return '' === Utils.trim(this.currentLine, ' ');
1178 };
1179  
1180 Parser.prototype.isCurrentLineComment = function() {
1181 var ltrimmedLine;
1182 ltrimmedLine = Utils.ltrim(this.currentLine, ' ');
1183 return ltrimmedLine.charAt(0) === '#';
1184 };
1185  
1186 Parser.prototype.cleanup = function(value) {
1187 var count, i, indent, j, l, len, len1, line, lines, ref, ref1, ref2, smallestIndent, trimmedValue;
1188 if (value.indexOf("\r") !== -1) {
1189 value = value.split("\r\n").join("\n").split("\r").join("\n");
1190 }
1191 count = 0;
1192 ref = this.PATTERN_YAML_HEADER.replaceAll(value, ''), value = ref[0], count = ref[1];
1193 this.offset += count;
1194 ref1 = this.PATTERN_LEADING_COMMENTS.replaceAll(value, '', 1), trimmedValue = ref1[0], count = ref1[1];
1195 if (count === 1) {
1196 this.offset += Utils.subStrCount(value, "\n") - Utils.subStrCount(trimmedValue, "\n");
1197 value = trimmedValue;
1198 }
1199 ref2 = this.PATTERN_DOCUMENT_MARKER_START.replaceAll(value, '', 1), trimmedValue = ref2[0], count = ref2[1];
1200 if (count === 1) {
1201 this.offset += Utils.subStrCount(value, "\n") - Utils.subStrCount(trimmedValue, "\n");
1202 value = trimmedValue;
1203 value = this.PATTERN_DOCUMENT_MARKER_END.replace(value, '');
1204 }
1205 lines = value.split("\n");
1206 smallestIndent = -1;
1207 for (j = 0, len = lines.length; j < len; j++) {
1208 line = lines[j];
1209 if (Utils.trim(line, ' ').length === 0) {
1210 continue;
1211 }
1212 indent = line.length - Utils.ltrim(line).length;
1213 if (smallestIndent === -1 || indent < smallestIndent) {
1214 smallestIndent = indent;
1215 }
1216 }
1217 if (smallestIndent > 0) {
1218 for (i = l = 0, len1 = lines.length; l < len1; i = ++l) {
1219 line = lines[i];
1220 lines[i] = line.slice(smallestIndent);
1221 }
1222 value = lines.join("\n");
1223 }
1224 return value;
1225 };
1226  
1227 Parser.prototype.isNextLineUnIndentedCollection = function(currentIndentation) {
1228 var notEOF, ret;
1229 if (currentIndentation == null) {
1230 currentIndentation = null;
1231 }
1232 if (currentIndentation == null) {
1233 currentIndentation = this.getCurrentLineIndentation();
1234 }
1235 notEOF = this.moveToNextLine();
1236 while (notEOF && this.isCurrentLineEmpty()) {
1237 notEOF = this.moveToNextLine();
1238 }
1239 if (false === notEOF) {
1240 return false;
1241 }
1242 ret = false;
1243 if (this.getCurrentLineIndentation() === currentIndentation && this.isStringUnIndentedCollectionItem(this.currentLine)) {
1244 ret = true;
1245 }
1246 this.moveToPreviousLine();
1247 return ret;
1248 };
1249  
1250 Parser.prototype.isStringUnIndentedCollectionItem = function() {
1251 return this.currentLine === '-' || this.currentLine.slice(0, 2) === '- ';
1252 };
1253  
1254 return Parser;
1255  
1256 })();
1257  
1258 module.exports = Parser;
1259  
1260  
1261 },{"./Exception/ParseException":4,"./Inline":5,"./Pattern":7,"./Utils":9}],7:[function(require,module,exports){
1262 var Pattern;
1263  
1264 Pattern = (function() {
1265 Pattern.prototype.regex = null;
1266  
1267 Pattern.prototype.rawRegex = null;
1268  
1269 Pattern.prototype.cleanedRegex = null;
1270  
1271 Pattern.prototype.mapping = null;
1272  
1273 function Pattern(rawRegex, modifiers) {
1274 var _char, capturingBracketNumber, cleanedRegex, i, len, mapping, name, part, subChar;
1275 if (modifiers == null) {
1276 modifiers = '';
1277 }
1278 cleanedRegex = '';
1279 len = rawRegex.length;
1280 mapping = null;
1281 capturingBracketNumber = 0;
1282 i = 0;
1283 while (i < len) {
1284 _char = rawRegex.charAt(i);
1285 if (_char === '\\') {
1286 cleanedRegex += rawRegex.slice(i, +(i + 1) + 1 || 9e9);
1287 i++;
1288 } else if (_char === '(') {
1289 if (i < len - 2) {
1290 part = rawRegex.slice(i, +(i + 2) + 1 || 9e9);
1291 if (part === '(?:') {
1292 i += 2;
1293 cleanedRegex += part;
1294 } else if (part === '(?<') {
1295 capturingBracketNumber++;
1296 i += 2;
1297 name = '';
1298 while (i + 1 < len) {
1299 subChar = rawRegex.charAt(i + 1);
1300 if (subChar === '>') {
1301 cleanedRegex += '(';
1302 i++;
1303 if (name.length > 0) {
1304 if (mapping == null) {
1305 mapping = {};
1306 }
1307 mapping[name] = capturingBracketNumber;
1308 }
1309 break;
1310 } else {
1311 name += subChar;
1312 }
1313 i++;
1314 }
1315 } else {
1316 cleanedRegex += _char;
1317 capturingBracketNumber++;
1318 }
1319 } else {
1320 cleanedRegex += _char;
1321 }
1322 } else {
1323 cleanedRegex += _char;
1324 }
1325 i++;
1326 }
1327 this.rawRegex = rawRegex;
1328 this.cleanedRegex = cleanedRegex;
1329 this.regex = new RegExp(this.cleanedRegex, 'g' + modifiers.replace('g', ''));
1330 this.mapping = mapping;
1331 }
1332  
1333 Pattern.prototype.exec = function(str) {
1334 var index, matches, name, ref;
1335 this.regex.lastIndex = 0;
1336 matches = this.regex.exec(str);
1337 if (matches == null) {
1338 return null;
1339 }
1340 if (this.mapping != null) {
1341 ref = this.mapping;
1342 for (name in ref) {
1343 index = ref[name];
1344 matches[name] = matches[index];
1345 }
1346 }
1347 return matches;
1348 };
1349  
1350 Pattern.prototype.test = function(str) {
1351 this.regex.lastIndex = 0;
1352 return this.regex.test(str);
1353 };
1354  
1355 Pattern.prototype.replace = function(str, replacement) {
1356 this.regex.lastIndex = 0;
1357 return str.replace(this.regex, replacement);
1358 };
1359  
1360 Pattern.prototype.replaceAll = function(str, replacement, limit) {
1361 var count;
1362 if (limit == null) {
1363 limit = 0;
1364 }
1365 this.regex.lastIndex = 0;
1366 count = 0;
1367 while (this.regex.test(str) && (limit === 0 || count < limit)) {
1368 this.regex.lastIndex = 0;
1369 str = str.replace(this.regex, '');
1370 count++;
1371 }
1372 return [str, count];
1373 };
1374  
1375 return Pattern;
1376  
1377 })();
1378  
1379 module.exports = Pattern;
1380  
1381  
1382 },{}],8:[function(require,module,exports){
1383 var Pattern, Unescaper, Utils;
1384  
1385 Utils = require('./Utils');
1386  
1387 Pattern = require('./Pattern');
1388  
1389 Unescaper = (function() {
1390 function Unescaper() {}
1391  
1392 Unescaper.PATTERN_ESCAPED_CHARACTER = new Pattern('\\\\([0abt\tnvfre "\\/\\\\N_LP]|x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8})');
1393  
1394 Unescaper.unescapeSingleQuotedString = function(value) {
1395 return value.replace(/\'\'/g, '\'');
1396 };
1397  
1398 Unescaper.unescapeDoubleQuotedString = function(value) {
1399 if (this._unescapeCallback == null) {
1400 this._unescapeCallback = (function(_this) {
1401 return function(str) {
1402 return _this.unescapeCharacter(str);
1403 };
1404 })(this);
1405 }
1406 return this.PATTERN_ESCAPED_CHARACTER.replace(value, this._unescapeCallback);
1407 };
1408  
1409 Unescaper.unescapeCharacter = function(value) {
1410 var ch;
1411 ch = String.fromCharCode;
1412 switch (value.charAt(1)) {
1413 case '0':
1414 return ch(0);
1415 case 'a':
1416 return ch(7);
1417 case 'b':
1418 return ch(8);
1419 case 't':
1420 return "\t";
1421 case "\t":
1422 return "\t";
1423 case 'n':
1424 return "\n";
1425 case 'v':
1426 return ch(11);
1427 case 'f':
1428 return ch(12);
1429 case 'r':
1430 return ch(13);
1431 case 'e':
1432 return ch(27);
1433 case ' ':
1434 return ' ';
1435 case '"':
1436 return '"';
1437 case '/':
1438 return '/';
1439 case '\\':
1440 return '\\';
1441 case 'N':
1442 return ch(0x0085);
1443 case '_':
1444 return ch(0x00A0);
1445 case 'L':
1446 return ch(0x2028);
1447 case 'P':
1448 return ch(0x2029);
1449 case 'x':
1450 return Utils.utf8chr(Utils.hexDec(value.substr(2, 2)));
1451 case 'u':
1452 return Utils.utf8chr(Utils.hexDec(value.substr(2, 4)));
1453 case 'U':
1454 return Utils.utf8chr(Utils.hexDec(value.substr(2, 8)));
1455 default:
1456 return '';
1457 }
1458 };
1459  
1460 return Unescaper;
1461  
1462 })();
1463  
1464 module.exports = Unescaper;
1465  
1466  
1467 },{"./Pattern":7,"./Utils":9}],9:[function(require,module,exports){
1468 var Pattern, Utils;
1469  
1470 Pattern = require('./Pattern');
1471  
1472 Utils = (function() {
1473 function Utils() {}
1474  
1475 Utils.REGEX_LEFT_TRIM_BY_CHAR = {};
1476  
1477 Utils.REGEX_RIGHT_TRIM_BY_CHAR = {};
1478  
1479 Utils.REGEX_SPACES = /\s+/g;
1480  
1481 Utils.REGEX_DIGITS = /^\d+$/;
1482  
1483 Utils.REGEX_OCTAL = /[^0-7]/gi;
1484  
1485 Utils.REGEX_HEXADECIMAL = /[^a-f0-9]/gi;
1486  
1487 Utils.PATTERN_DATE = new Pattern('^' + '(?<year>[0-9][0-9][0-9][0-9])' + '-(?<month>[0-9][0-9]?)' + '-(?<day>[0-9][0-9]?)' + '(?:(?:[Tt]|[ \t]+)' + '(?<hour>[0-9][0-9]?)' + ':(?<minute>[0-9][0-9])' + ':(?<second>[0-9][0-9])' + '(?:\.(?<fraction>[0-9]*))?' + '(?:[ \t]*(?<tz>Z|(?<tz_sign>[-+])(?<tz_hour>[0-9][0-9]?)' + '(?::(?<tz_minute>[0-9][0-9]))?))?)?' + '$', 'i');
1488  
1489 Utils.LOCAL_TIMEZONE_OFFSET = new Date().getTimezoneOffset() * 60 * 1000;
1490  
1491 Utils.trim = function(str, _char) {
1492 var regexLeft, regexRight;
1493 if (_char == null) {
1494 _char = '\\s';
1495 }
1496 return str.trim();
1497 regexLeft = this.REGEX_LEFT_TRIM_BY_CHAR[_char];
1498 if (regexLeft == null) {
1499 this.REGEX_LEFT_TRIM_BY_CHAR[_char] = regexLeft = new RegExp('^' + _char + '' + _char + '*');
1500 }
1501 regexLeft.lastIndex = 0;
1502 regexRight = this.REGEX_RIGHT_TRIM_BY_CHAR[_char];
1503 if (regexRight == null) {
1504 this.REGEX_RIGHT_TRIM_BY_CHAR[_char] = regexRight = new RegExp(_char + '' + _char + '*$');
1505 }
1506 regexRight.lastIndex = 0;
1507 return str.replace(regexLeft, '').replace(regexRight, '');
1508 };
1509  
1510 Utils.ltrim = function(str, _char) {
1511 var regexLeft;
1512 if (_char == null) {
1513 _char = '\\s';
1514 }
1515 regexLeft = this.REGEX_LEFT_TRIM_BY_CHAR[_char];
1516 if (regexLeft == null) {
1517 this.REGEX_LEFT_TRIM_BY_CHAR[_char] = regexLeft = new RegExp('^' + _char + '' + _char + '*');
1518 }
1519 regexLeft.lastIndex = 0;
1520 return str.replace(regexLeft, '');
1521 };
1522  
1523 Utils.rtrim = function(str, _char) {
1524 var regexRight;
1525 if (_char == null) {
1526 _char = '\\s';
1527 }
1528 regexRight = this.REGEX_RIGHT_TRIM_BY_CHAR[_char];
1529 if (regexRight == null) {
1530 this.REGEX_RIGHT_TRIM_BY_CHAR[_char] = regexRight = new RegExp(_char + '' + _char + '*$');
1531 }
1532 regexRight.lastIndex = 0;
1533 return str.replace(regexRight, '');
1534 };
1535  
1536 Utils.isEmpty = function(value) {
1537 return !value || value === '' || value === '0' || (value instanceof Array && value.length === 0);
1538 };
1539  
1540 Utils.subStrCount = function(string, subString, start, length) {
1541 var c, i, j, len, ref, sublen;
1542 c = 0;
1543 string = '' + string;
1544 subString = '' + subString;
1545 if (start != null) {
1546 string = string.slice(start);
1547 }
1548 if (length != null) {
1549 string = string.slice(0, length);
1550 }
1551 len = string.length;
1552 sublen = subString.length;
1553 for (i = j = 0, ref = len; 0 <= ref ? j < ref : j > ref; i = 0 <= ref ? ++j : --j) {
1554 if (subString === string.slice(i, sublen)) {
1555 c++;
1556 i += sublen - 1;
1557 }
1558 }
1559 return c;
1560 };
1561  
1562 Utils.isDigits = function(input) {
1563 this.REGEX_DIGITS.lastIndex = 0;
1564 return this.REGEX_DIGITS.test(input);
1565 };
1566  
1567 Utils.octDec = function(input) {
1568 this.REGEX_OCTAL.lastIndex = 0;
1569 return parseInt((input + '').replace(this.REGEX_OCTAL, ''), 8);
1570 };
1571  
1572 Utils.hexDec = function(input) {
1573 this.REGEX_HEXADECIMAL.lastIndex = 0;
1574 input = this.trim(input);
1575 if ((input + '').slice(0, 2) === '0x') {
1576 input = (input + '').slice(2);
1577 }
1578 return parseInt((input + '').replace(this.REGEX_HEXADECIMAL, ''), 16);
1579 };
1580  
1581 Utils.utf8chr = function(c) {
1582 var ch;
1583 ch = String.fromCharCode;
1584 if (0x80 > (c %= 0x200000)) {
1585 return ch(c);
1586 }
1587 if (0x800 > c) {
1588 return ch(0xC0 | c >> 6) + ch(0x80 | c & 0x3F);
1589 }
1590 if (0x10000 > c) {
1591 return ch(0xE0 | c >> 12) + ch(0x80 | c >> 6 & 0x3F) + ch(0x80 | c & 0x3F);
1592 }
1593 return ch(0xF0 | c >> 18) + ch(0x80 | c >> 12 & 0x3F) + ch(0x80 | c >> 6 & 0x3F) + ch(0x80 | c & 0x3F);
1594 };
1595  
1596 Utils.parseBoolean = function(input, strict) {
1597 var lowerInput;
1598 if (strict == null) {
1599 strict = true;
1600 }
1601 if (typeof input === 'string') {
1602 lowerInput = input.toLowerCase();
1603 if (!strict) {
1604 if (lowerInput === 'no') {
1605 return false;
1606 }
1607 }
1608 if (lowerInput === '0') {
1609 return false;
1610 }
1611 if (lowerInput === 'false') {
1612 return false;
1613 }
1614 if (lowerInput === '') {
1615 return false;
1616 }
1617 return true;
1618 }
1619 return !!input;
1620 };
1621  
1622 Utils.isNumeric = function(input) {
1623 this.REGEX_SPACES.lastIndex = 0;
1624 return typeof input === 'number' || typeof input === 'string' && !isNaN(input) && input.replace(this.REGEX_SPACES, '') !== '';
1625 };
1626  
1627 Utils.stringToDate = function(str) {
1628 var date, day, fraction, hour, info, minute, month, second, tz_hour, tz_minute, tz_offset, year;
1629 if (!(str != null ? str.length : void 0)) {
1630 return null;
1631 }
1632 info = this.PATTERN_DATE.exec(str);
1633 if (!info) {
1634 return null;
1635 }
1636 year = parseInt(info.year, 10);
1637 month = parseInt(info.month, 10) - 1;
1638 day = parseInt(info.day, 10);
1639 if (info.hour == null) {
1640 date = new Date(Date.UTC(year, month, day));
1641 return date;
1642 }
1643 hour = parseInt(info.hour, 10);
1644 minute = parseInt(info.minute, 10);
1645 second = parseInt(info.second, 10);
1646 if (info.fraction != null) {
1647 fraction = info.fraction.slice(0, 3);
1648 while (fraction.length < 3) {
1649 fraction += '0';
1650 }
1651 fraction = parseInt(fraction, 10);
1652 } else {
1653 fraction = 0;
1654 }
1655 if (info.tz != null) {
1656 tz_hour = parseInt(info.tz_hour, 10);
1657 if (info.tz_minute != null) {
1658 tz_minute = parseInt(info.tz_minute, 10);
1659 } else {
1660 tz_minute = 0;
1661 }
1662 tz_offset = (tz_hour * 60 + tz_minute) * 60000;
1663 if ('-' === info.tz_sign) {
1664 tz_offset *= -1;
1665 }
1666 }
1667 date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
1668 if (tz_offset) {
1669 date.setTime(date.getTime() + tz_offset);
1670 }
1671 return date;
1672 };
1673  
1674 Utils.strRepeat = function(str, number) {
1675 var i, res;
1676 res = '';
1677 i = 0;
1678 while (i < number) {
1679 res += str;
1680 i++;
1681 }
1682 return res;
1683 };
1684  
1685 Utils.getStringFromFile = function(path, callback) {
1686 var data, fs, j, len1, name, ref, req, xhr;
1687 if (callback == null) {
1688 callback = null;
1689 }
1690 xhr = null;
1691 if (typeof window !== "undefined" && window !== null) {
1692 if (window.XMLHttpRequest) {
1693 xhr = new XMLHttpRequest();
1694 } else if (window.ActiveXObject) {
1695 ref = ["Msxml2.XMLHTTP.6.0", "Msxml2.XMLHTTP.3.0", "Msxml2.XMLHTTP", "Microsoft.XMLHTTP"];
1696 for (j = 0, len1 = ref.length; j < len1; j++) {
1697 name = ref[j];
1698 try {
1699 xhr = new ActiveXObject(name);
1700 } catch (undefined) {}
1701 }
1702 }
1703 }
1704 if (xhr != null) {
1705 if (callback != null) {
1706 xhr.onreadystatechange = function() {
1707 if (xhr.readyState === 4) {
1708 if (xhr.status === 200 || xhr.status === 0) {
1709 return callback(xhr.responseText);
1710 } else {
1711 return callback(null);
1712 }
1713 }
1714 };
1715 xhr.open('GET', path, true);
1716 return xhr.send(null);
1717 } else {
1718 xhr.open('GET', path, false);
1719 xhr.send(null);
1720 if (xhr.status === 200 || xhr.status === 0) {
1721 return xhr.responseText;
1722 }
1723 return null;
1724 }
1725 } else {
1726 req = require;
1727 fs = req('fs');
1728 if (callback != null) {
1729 return fs.readFile(path, function(err, data) {
1730 if (err) {
1731 return callback(null);
1732 } else {
1733 return callback(String(data));
1734 }
1735 });
1736 } else {
1737 data = fs.readFileSync(path);
1738 if (data != null) {
1739 return String(data);
1740 }
1741 return null;
1742 }
1743 }
1744 };
1745  
1746 return Utils;
1747  
1748 })();
1749  
1750 module.exports = Utils;
1751  
1752  
1753 },{"./Pattern":7}],10:[function(require,module,exports){
1754 var Dumper, Parser, Utils, Yaml;
1755  
1756 Parser = require('./Parser');
1757  
1758 Dumper = require('./Dumper');
1759  
1760 Utils = require('./Utils');
1761  
1762 Yaml = (function() {
1763 function Yaml() {}
1764  
1765 Yaml.parse = function(input, exceptionOnInvalidType, objectDecoder) {
1766 if (exceptionOnInvalidType == null) {
1767 exceptionOnInvalidType = false;
1768 }
1769 if (objectDecoder == null) {
1770 objectDecoder = null;
1771 }
1772 return new Parser().parse(input, exceptionOnInvalidType, objectDecoder);
1773 };
1774  
1775 Yaml.parseFile = function(path, callback, exceptionOnInvalidType, objectDecoder) {
1776 var input;
1777 if (callback == null) {
1778 callback = null;
1779 }
1780 if (exceptionOnInvalidType == null) {
1781 exceptionOnInvalidType = false;
1782 }
1783 if (objectDecoder == null) {
1784 objectDecoder = null;
1785 }
1786 if (callback != null) {
1787 return Utils.getStringFromFile(path, (function(_this) {
1788 return function(input) {
1789 var result;
1790 result = null;
1791 if (input != null) {
1792 result = _this.parse(input, exceptionOnInvalidType, objectDecoder);
1793 }
1794 callback(result);
1795 };
1796 })(this));
1797 } else {
1798 input = Utils.getStringFromFile(path);
1799 if (input != null) {
1800 return this.parse(input, exceptionOnInvalidType, objectDecoder);
1801 }
1802 return null;
1803 }
1804 };
1805  
1806 Yaml.dump = function(input, inline, indent, exceptionOnInvalidType, objectEncoder) {
1807 var yaml;
1808 if (inline == null) {
1809 inline = 2;
1810 }
1811 if (indent == null) {
1812 indent = 4;
1813 }
1814 if (exceptionOnInvalidType == null) {
1815 exceptionOnInvalidType = false;
1816 }
1817 if (objectEncoder == null) {
1818 objectEncoder = null;
1819 }
1820 yaml = new Dumper();
1821 yaml.indentation = indent;
1822 return yaml.dump(input, inline, 0, exceptionOnInvalidType, objectEncoder);
1823 };
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  
1836 Yaml.stringify = function(input, inline, indent, exceptionOnInvalidType, objectEncoder) {
1837 return this.dump(input, inline, indent, exceptionOnInvalidType, objectEncoder);
1838 };
1839  
1840 Yaml.load = function(path, callback, exceptionOnInvalidType, objectDecoder) {
1841 return this.parseFile(path, callback, exceptionOnInvalidType, objectDecoder);
1842 };
1843  
1844 return Yaml;
1845  
1846 })();
1847  
1848 if (typeof window !== "undefined" && window !== null) {
1849 window.YAML = Yaml;
1850 }
1851  
1852 if (typeof window === "undefined" || window === null) {
1853 this.YAML = Yaml;
1854 }
1855  
1856 module.exports = Yaml;
1857  
1858  
1859 },{"./Dumper":1,"./Parser":6,"./Utils":9}]},{},[10]);