/bower_components/yaml.js/src/Inline.coffee |
@@ -4,7 +4,6 @@ |
Escaper = require './Escaper' |
Utils = require './Utils' |
ParseException = require './Exception/ParseException' |
ParseMore = require './Exception/ParseMore' |
DumpException = require './Exception/DumpException' |
|
# Inline YAML parsing and dumping |
@@ -212,13 +211,13 @@ |
# |
# @return [String] A YAML string |
# |
# @throw [ParseMore] When malformed inline YAML string is parsed |
# @throw [ParseException] When malformed inline YAML string is parsed |
# |
@parseQuotedScalar: (scalar, context) -> |
{i} = context |
|
unless match = @PATTERN_QUOTED_SCALAR.exec scalar[i..] |
throw new ParseMore 'Malformed inline YAML string ('+scalar[i..]+').' |
throw new ParseException 'Malformed inline YAML string ('+scalar[i..]+').' |
|
output = match[0].substr(1, match[0].length - 2) |
|
@@ -240,7 +239,7 @@ |
# |
# @return [String] A YAML string |
# |
# @throw [ParseMore] When malformed inline YAML string is parsed |
# @throw [ParseException] When malformed inline YAML string is parsed |
# |
@parseSequence: (sequence, context) -> |
output = [] |
@@ -283,7 +282,7 @@ |
|
++i |
|
throw new ParseMore 'Malformed inline YAML string '+sequence |
throw new ParseException 'Malformed inline YAML string '+sequence |
|
|
# Parses a mapping to a YAML string. |
@@ -293,7 +292,7 @@ |
# |
# @return [String] A YAML string |
# |
# @throw [ParseMore] When malformed inline YAML string is parsed |
# @throw [ParseException] When malformed inline YAML string is parsed |
# |
@parseMapping: (mapping, context) -> |
output = {} |
@@ -365,7 +364,7 @@ |
if done |
break |
|
throw new ParseMore 'Malformed inline YAML string '+mapping |
throw new ParseException 'Malformed inline YAML string '+mapping |
|
|
# Evaluates scalars and replaces magic values. |
/bower_components/yaml.js/src/Parser.coffee |
@@ -3,7 +3,6 @@ |
Pattern = require './Pattern' |
Utils = require './Utils' |
ParseException = require './Exception/ParseException' |
ParseMore = require './Exception/ParseMore' |
|
# Parser parses YAML strings to convert them to JavaScript objects. |
# |
@@ -20,10 +19,10 @@ |
PATTERN_DECIMAL: new Pattern '\\d+' |
PATTERN_INDENT_SPACES: new Pattern '^ +' |
PATTERN_TRAILING_LINES: new Pattern '(\n*)$' |
PATTERN_YAML_HEADER: new Pattern '^\\%YAML[: ][\\d\\.]+.*\n', 'm' |
PATTERN_LEADING_COMMENTS: new Pattern '^(\\#.*?\n)+', 'm' |
PATTERN_DOCUMENT_MARKER_START: new Pattern '^\\-\\-\\-.*?\n', 'm' |
PATTERN_DOCUMENT_MARKER_END: new Pattern '^\\.\\.\\.\\s*$', 'm' |
PATTERN_YAML_HEADER: new Pattern '^\\%YAML[: ][\\d\\.]+.*\n' |
PATTERN_LEADING_COMMENTS: new Pattern '^(\\#.*?\n)+' |
PATTERN_DOCUMENT_MARKER_START: new Pattern '^\\-\\-\\-.*?\n' |
PATTERN_DOCUMENT_MARKER_END: new Pattern '^\\.\\.\\.\\s*$' |
PATTERN_FOLDED_SCALAR_BY_INDENTATION: {} |
|
# Context types |
@@ -334,16 +333,17 @@ |
if indent is newIndent |
removeComments = not removeCommentsPattern.test @currentLine |
|
if removeComments and @isCurrentLineComment() |
continue |
if isItUnindentedCollection and not @isStringUnIndentedCollectionItem(@currentLine) and indent is newIndent |
@moveToPreviousLine() |
break |
|
if @isCurrentLineBlank() |
data.push @currentLine[newIndent..] |
continue |
|
if isItUnindentedCollection and not @isStringUnIndentedCollectionItem(@currentLine) and indent is newIndent |
@moveToPreviousLine() |
break |
if removeComments and @isCurrentLineComment() |
if indent is newIndent |
continue |
|
if indent >= newIndent |
data.push @currentLine[newIndent..] |
@@ -416,23 +416,26 @@ |
else |
return val |
|
# Value can be multiline compact sequence or mapping or string |
if value.charAt(0) in ['[', '{', '"', "'"] |
while true |
try |
return Inline.parse value, exceptionOnInvalidType, objectDecoder |
catch e |
if e instanceof ParseMore and @moveToNextLine() |
value += "\n" + Utils.trim(@currentLine, ' ') |
else |
# Try to parse multiline compact sequence or mapping |
if value.charAt(0) in ['[', '{'] and e instanceof ParseException and @isNextLineIndented() |
value += "\n" + @getNextEmbedBlock() |
try |
return Inline.parse value, exceptionOnInvalidType, objectDecoder |
catch e |
e.parsedLine = @getRealCurrentLineNb() + 1 |
e.snippet = @currentLine |
|
throw e |
|
else |
if @isNextLineIndented() |
value += "\n" + @getNextEmbedBlock() |
return Inline.parse value, exceptionOnInvalidType, objectDecoder |
e.parsedLine = @getRealCurrentLineNb() + 1 |
e.snippet = @currentLine |
|
throw e |
|
return |
|
|
/bower_components/yaml.js/src/Utils.coffee |
@@ -37,6 +37,7 @@ |
# @return [String] A trimmed string |
# |
@trim: (str, _char = '\\s') -> |
return str.trim() |
regexLeft = @REGEX_LEFT_TRIM_BY_CHAR[_char] |
unless regexLeft? |
@REGEX_LEFT_TRIM_BY_CHAR[_char] = regexLeft = new RegExp '^'+_char+''+_char+'*' |
@@ -78,7 +79,7 @@ |
return str.replace(regexRight, '') |
|
|
# Checks if the given value is empty (null, undefined, empty string, string '0', empty Array, empty Object) |
# Checks if the given value is empty (null, undefined, empty string, string '0') |
# |
# @param [Object] value The value to check |
# |
@@ -85,16 +86,8 @@ |
# @return [Boolean] true if the value is empty |
# |
@isEmpty: (value) -> |
return not(value) or value is '' or value is '0' or (value instanceof Array and value.length is 0) or @isEmptyObject(value) |
return not(value) or value is '' or value is '0' or (value instanceof Array and value.length is 0) |
|
# Checks if the given value is an empty object |
# |
# @param [Object] value The value to check |
# |
# @return [Boolean] true if the value is empty and is an object |
# |
@isEmptyObject: (value) -> |
return value instanceof Object and (k for own k of value).length is 0 |
|
# Counts the number of occurences of subString inside string |
# |
@@ -265,7 +258,7 @@ |
# Compute date |
date = new Date Date.UTC(year, month, day, hour, minute, second, fraction) |
if tz_offset |
date.setTime date.getTime() - tz_offset |
date.setTime date.getTime() + tz_offset |
|
return date |
|
/bower_components/yaml.js/src/Yaml.coffee |
@@ -82,6 +82,20 @@ |
return yaml.dump(input, inline, 0, exceptionOnInvalidType, objectEncoder) |
|
|
# Registers .yml extension to work with node's require() function. |
# |
@register: -> |
require_handler = (module, filename) -> |
# Fill in result |
module.exports = YAML.parseFile filename |
|
# Register require extensions only if we're on node.js |
# hack for browserify |
if require?.extensions? |
require.extensions['.yml'] = require_handler |
require.extensions['.yaml'] = require_handler |
|
|
# Alias of dump() method for compatibility reasons. |
# |
@stringify: (input, inline, indent, exceptionOnInvalidType, objectEncoder) -> |