diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2009-09-29 20:15:02 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2009-09-29 20:15:02 -0700 |
commit | 5e5da976f0ffb2bf6de72242b15dd24f95636483 (patch) | |
tree | cb8246d517f7c36c05ee3fe91e3a333f718e62d6 /lib | |
parent | b17beefedab46e8a3c511c252436be1f8da40fcc (diff) | |
download | psych-5e5da976f0ffb2bf6de72242b15dd24f95636483.zip |
list round trips
Diffstat (limited to 'lib')
-rw-r--r-- | lib/psych/ruby.rb | 2 | ||||
-rw-r--r-- | lib/psych/visitors/yast_builder.rb | 16 |
2 files changed, 14 insertions, 4 deletions
diff --git a/lib/psych/ruby.rb b/lib/psych/ruby.rb index 6802391..f63fee1 100644 --- a/lib/psych/ruby.rb +++ b/lib/psych/ruby.rb @@ -1,4 +1,4 @@ -[Object, String, Class, Hash].each do |klass| +[Object, String, Class, Hash, Array].each do |klass| klass.send(:remove_method, :to_yaml) end diff --git a/lib/psych/visitors/yast_builder.rb b/lib/psych/visitors/yast_builder.rb index 00f533f..aad42d3 100644 --- a/lib/psych/visitors/yast_builder.rb +++ b/lib/psych/visitors/yast_builder.rb @@ -29,9 +29,7 @@ module Psych end visitor_for(::Hash) do |o| - map = Nodes::Mapping.new - @stack.last.children << map - @stack.push map + @stack.push append Nodes::Mapping.new o.each do |k,v| k.accept self @@ -40,6 +38,18 @@ module Psych @stack.pop end + + visitor_for(::Array) do |o| + @stack.push append Nodes::Sequence.new + o.each { |c| c.accept self } + @stack.pop + end + + private + def append o + @stack.last.children << o + o + end end end end |