diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2015-03-30 19:08:10 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2015-03-30 19:08:10 -0700 |
commit | e1d7f705da01349b93420cd7f54576949d694a69 (patch) | |
tree | 0c2e38d322e1cd9bd2321d9d9bd64ef2c711e7ca | |
parent | 24ff7855ca2f62e59fc951fa30b225f42369c2a2 (diff) | |
parent | 3ed6bf733c6e2401780115b0cd64736eca5f2244 (diff) | |
download | psych-e1d7f705da01349b93420cd7f54576949d694a69.tar.gz |
Merge pull request #229 from filialpails/patch-1
Fix mappings with !str tags
-rw-r--r-- | lib/psych/visitors/to_ruby.rb | 4 | ||||
-rw-r--r-- | test/psych/visitors/test_to_ruby.rb | 7 |
2 files changed, 9 insertions, 2 deletions
diff --git a/lib/psych/visitors/to_ruby.rb b/lib/psych/visitors/to_ruby.rb index b68abb6..ea3ab1c 100644 --- a/lib/psych/visitors/to_ruby.rb +++ b/lib/psych/visitors/to_ruby.rb @@ -61,7 +61,7 @@ module Psych case o.tag when '!binary', 'tag:yaml.org,2002:binary' o.value.unpack('m').first - when /^!(?:str|ruby\/string)(?::(.*))?/, 'tag:yaml.org,2002:str' + when /^!(?:str|ruby\/string)(?::(.*))?$/, 'tag:yaml.org,2002:str' klass = resolve_class($1) if klass klass.allocate.replace o.value @@ -208,7 +208,7 @@ module Psych obj end - when /^!(?:str|ruby\/string)(?::(.*))?/, 'tag:yaml.org,2002:str' + when /^!(?:str|ruby\/string)(?::(.*))?$/, 'tag:yaml.org,2002:str' klass = resolve_class($1) members = {} string = nil diff --git a/test/psych/visitors/test_to_ruby.rb b/test/psych/visitors/test_to_ruby.rb index c13d980..5c6ba2b 100644 --- a/test/psych/visitors/test_to_ruby.rb +++ b/test/psych/visitors/test_to_ruby.rb @@ -321,6 +321,13 @@ description: assert_equal %w{ foo foo }, list assert_equal list[0].object_id, list[1].object_id end + + def test_mapping_with_str_tag + mapping = Nodes::Mapping.new(nil, '!strawberry') + mapping.children << Nodes::Scalar.new('foo') + mapping.children << Nodes::Scalar.new('bar') + assert_equal({'foo' => 'bar'}, mapping.to_ruby) + end end end end |