11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/lookbook/services/tags/key_value_tag_parser.rb', line 11
def call
text.strip.match(KEY_VALUE_REGEX) do |matches|
key = matches[1]
value = begin
YAML.safe_load(matches[2] || "~")
rescue ::Psych::SyntaxError => exception
raise ParserError.new("Invalid YAML in tag text '#{@text}'", scope: "key_value_tag.parser", original: exception)
end
return [key, value]
end
raise ParserError.new("Could not parse key:value pair from '#{@text}'", scope: "key_value_tag.parser")
end
|