lib/fixture_fox/token.rb in fixture_fox-0.1.2 vs lib/fixture_fox/token.rb in fixture_fox-0.1.3
- old
+ new
@@ -129,17 +129,22 @@
@value += litt[i]
i += 1
end
end
+ # Inline arrays are split on ',' and on blanks. '\' is the escape
+ # character
+ #
+ # FIXME: Quotes doesn't override separator. Eg. this throws an
+ # exception: ['hello world']
when /^(\[\s*)(.*)\]$/
i += $1.size
elements = $2
- matches = elements.split(/(\s*(?<!(?<!\\{2})\\),\s*)/)
+ matches = elements.split(/(\s*(?<!(?<!\\{2})\\)[, ]\s*)/)
@value = []
while element = matches.shift
- unescaped_element = element.sub(/\\/, "")
+ unescaped_element = element.gsub(/\\/, "")
@value << Value.new(file, lineno, initial_indent, i, unescaped_element).value
i += element.size + (matches.shift&.size || 0)
end
@klass = Array