diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2014-08-29 14:03:18 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2014-08-29 14:03:18 -0700 |
commit | 08092b0f089f914388bfdf4775fb260a80ef7361 (patch) | |
tree | 2e5d64942027fb8aa860592a9e3456c176231e65 /lib/psych | |
parent | de391773646546deb81f9ed0dabaa9c828356f98 (diff) | |
download | psych-08092b0f089f914388bfdf4775fb260a80ef7361.zip |
* ext/psych/lib/psych/visitors/to_ruby.rb: quoted "<<" strings
should not be treated as merge keys.
* ext/psych/lib/psych/visitors/yaml_tree.rb: hashes with keys
containing "<<" should roundtrip.
* test/psych/test_merge_keys.rb: test for change. Fixes GH #203
fixes #203
Diffstat (limited to 'lib/psych')
-rw-r--r-- | lib/psych/visitors/to_ruby.rb | 2 | ||||
-rw-r--r-- | lib/psych/visitors/yaml_tree.rb | 5 |
2 files changed, 6 insertions, 1 deletions
diff --git a/lib/psych/visitors/to_ruby.rb b/lib/psych/visitors/to_ruby.rb index 234cabc..984bc84 100644 --- a/lib/psych/visitors/to_ruby.rb +++ b/lib/psych/visitors/to_ruby.rb @@ -305,7 +305,7 @@ module Psych key = accept(k) val = accept(v) - if key == '<<' + if key == '<<' && k.tag != "tag:yaml.org,2002:str" case v when Nodes::Alias begin diff --git a/lib/psych/visitors/yaml_tree.rb b/lib/psych/visitors/yaml_tree.rb index 2afedb7..d73d91a 100644 --- a/lib/psych/visitors/yaml_tree.rb +++ b/lib/psych/visitors/yaml_tree.rb @@ -291,6 +291,11 @@ module Psych quote = false elsif o =~ /\n/ style = Nodes::Scalar::LITERAL + elsif o == '<<' + style = Nodes::Scalar::SINGLE_QUOTED + tag = 'tag:yaml.org,2002:str' + plain = false + quote = false elsif o =~ /^\W[^"]*$/ style = Nodes::Scalar::DOUBLE_QUOTED else |