summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/psych/visitors/to_ruby.rb4
-rw-r--r--test/visitors/test_to_ruby.rb14
2 files changed, 18 insertions, 0 deletions
diff --git a/lib/psych/visitors/to_ruby.rb b/lib/psych/visitors/to_ruby.rb
index a4e6152..27b7778 100644
--- a/lib/psych/visitors/to_ruby.rb
+++ b/lib/psych/visitors/to_ruby.rb
@@ -18,6 +18,10 @@ module Psych
visitor_for(Nodes::Document) do |o|
o.root.accept self
end
+
+ visitor_for(Nodes::Stream) do |o|
+ o.children.map { |c| c.accept self }
+ end
end
end
end
diff --git a/test/visitors/test_to_ruby.rb b/test/visitors/test_to_ruby.rb
index c295caf..c7caf47 100644
--- a/test/visitors/test_to_ruby.rb
+++ b/test/visitors/test_to_ruby.rb
@@ -34,6 +34,20 @@ module Psych
doc.children << Nodes::Scalar.new('foo')
assert_equal 'foo', doc.to_ruby
end
+
+ def test_stream
+ a = Nodes::Document.new
+ a.children << Nodes::Scalar.new('foo')
+
+ b = Nodes::Document.new
+ b.children << Nodes::Scalar.new('bar')
+
+ stream = Nodes::Stream.new
+ stream.children << a
+ stream.children << b
+
+ assert_equal %w{ foo bar }, stream.to_ruby
+ end
end
end
end