scratch

Subversion Repositories:
Compare Path: Rev
With Path: Rev
?path1? @ 75  →  ?path2? @ 125
/bower_components/yaml.js/src/Exception/ParseMore.coffee
@@ -0,0 +1,12 @@
 
class ParseMore extends Error
 
constructor: (@message, @parsedLine, @snippet) ->
 
toString: ->
if @parsedLine? and @snippet?
return '<ParseMore> ' + @message + ' (line ' + @parsedLine + ': \'' + @snippet + '\')'
else
return '<ParseMore> ' + @message
 
module.exports = ParseMore
/bower_components/yaml.js/src/Inline.coffee
@@ -4,6 +4,7 @@
Escaper = require './Escaper'
Utils = require './Utils'
ParseException = require './Exception/ParseException'
ParseMore = require './Exception/ParseMore'
DumpException = require './Exception/DumpException'
 
# Inline YAML parsing and dumping
@@ -211,13 +212,13 @@
#
# @return [String] A YAML string
#
# @throw [ParseException] When malformed inline YAML string is parsed
# @throw [ParseMore] When malformed inline YAML string is parsed
#
@parseQuotedScalar: (scalar, context) ->
{i} = context
 
unless match = @PATTERN_QUOTED_SCALAR.exec scalar[i..]
throw new ParseException 'Malformed inline YAML string ('+scalar[i..]+').'
throw new ParseMore 'Malformed inline YAML string ('+scalar[i..]+').'
 
output = match[0].substr(1, match[0].length - 2)
 
@@ -239,7 +240,7 @@
#
# @return [String] A YAML string
#
# @throw [ParseException] When malformed inline YAML string is parsed
# @throw [ParseMore] When malformed inline YAML string is parsed
#
@parseSequence: (sequence, context) ->
output = []
@@ -282,7 +283,7 @@
 
++i
 
throw new ParseException 'Malformed inline YAML string '+sequence
throw new ParseMore 'Malformed inline YAML string '+sequence
 
 
# Parses a mapping to a YAML string.
@@ -292,7 +293,7 @@
#
# @return [String] A YAML string
#
# @throw [ParseException] When malformed inline YAML string is parsed
# @throw [ParseMore] When malformed inline YAML string is parsed
#
@parseMapping: (mapping, context) ->
output = {}
@@ -364,7 +365,7 @@
if done
break
 
throw new ParseException 'Malformed inline YAML string '+mapping
throw new ParseMore 'Malformed inline YAML string '+mapping
 
 
# Evaluates scalars and replaces magic values.
/bower_components/yaml.js/src/Parser.coffee
@@ -3,6 +3,7 @@
Pattern = require './Pattern'
Utils = require './Utils'
ParseException = require './Exception/ParseException'
ParseMore = require './Exception/ParseMore'
 
# Parser parses YAML strings to convert them to JavaScript objects.
#
@@ -19,10 +20,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'
PATTERN_LEADING_COMMENTS: new Pattern '^(\\#.*?\n)+'
PATTERN_DOCUMENT_MARKER_START: new Pattern '^\\-\\-\\-.*?\n'
PATTERN_DOCUMENT_MARKER_END: new Pattern '^\\.\\.\\.\\s*$'
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_FOLDED_SCALAR_BY_INDENTATION: {}
 
# Context types
@@ -333,17 +334,16 @@
if indent is newIndent
removeComments = not removeCommentsPattern.test @currentLine
 
if isItUnindentedCollection and not @isStringUnIndentedCollectionItem(@currentLine) and indent is newIndent
@moveToPreviousLine()
break
if removeComments and @isCurrentLineComment()
continue
 
if @isCurrentLineBlank()
data.push @currentLine[newIndent..]
continue
 
if removeComments and @isCurrentLineComment()
if indent is newIndent
continue
if isItUnindentedCollection and not @isStringUnIndentedCollectionItem(@currentLine) and indent is newIndent
@moveToPreviousLine()
break
 
if indent >= newIndent
data.push @currentLine[newIndent..]
@@ -416,26 +416,23 @@
else
return val
 
try
return Inline.parse value, exceptionOnInvalidType, objectDecoder
catch e
# Try to parse multiline compact sequence or mapping
if value.charAt(0) in ['[', '{'] and e instanceof ParseException and @isNextLineIndented()
value += "\n" + @getNextEmbedBlock()
# 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
e.parsedLine = @getRealCurrentLineNb() + 1
e.snippet = @currentLine
if e instanceof ParseMore and @moveToNextLine()
value += "\n" + Utils.trim(@currentLine, ' ')
else
e.parsedLine = @getRealCurrentLineNb() + 1
e.snippet = @currentLine
throw e
else
if @isNextLineIndented()
value += "\n" + @getNextEmbedBlock()
return Inline.parse value, exceptionOnInvalidType, objectDecoder
 
throw e
 
else
e.parsedLine = @getRealCurrentLineNb() + 1
e.snippet = @currentLine
 
throw e
 
return
 
 
/bower_components/yaml.js/src/Pattern.coffee
@@ -134,7 +134,7 @@
count = 0
while @regex.test(str) and (limit is 0 or count < limit)
@regex.lastIndex = 0
str = str.replace @regex, ''
str = str.replace @regex, replacement
count++
return [str, count]
/bower_components/yaml.js/src/Utils.coffee
@@ -37,7 +37,6 @@
# @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+'*'
@@ -79,7 +78,7 @@
return str.replace(regexRight, '')
 
 
# Checks if the given value is empty (null, undefined, empty string, string '0')
# Checks if the given value is empty (null, undefined, empty string, string '0', empty Array, empty Object)
#
# @param [Object] value The value to check
#
@@ -86,8 +85,16 @@
# @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)
return not(value) or value is '' or value is '0' or (value instanceof Array and value.length is 0) or @isEmptyObject(value)
 
# 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
#
@@ -100,15 +107,15 @@
#
@subStrCount: (string, subString, start, length) ->
c = 0
 
string = '' + string
subString = '' + subString
 
if start?
string = string[start..]
if length?
string = string[0...length]
 
len = string.length
sublen = subString.length
for i in [0...len]
@@ -115,7 +122,7 @@
if subString is string[i...sublen]
c++
i += sublen - 1
 
return c
 
 
@@ -258,7 +265,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
 
@@ -308,7 +315,7 @@
callback(null)
xhr.open 'GET', path, true
xhr.send null
 
else
# Sync
xhr.open 'GET', path, false
/bower_components/yaml.js/src/Yaml.coffee
@@ -82,20 +82,6 @@
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) ->