summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2009-09-28 15:44:37 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2009-09-28 15:44:37 -0700
commitcbf2a14ec5fc5b6fe0b576c2df13cf5e29cefbb3 (patch)
treedbfe4b8deff9869c9f5fdc714825fd414a821f2e /lib
parentc48e3e528685d6127193de67721b2707c0675936 (diff)
downloadpsych-cbf2a14ec5fc5b6fe0b576c2df13cf5e29cefbb3.zip
aliases starting to work
Diffstat (limited to 'lib')
-rw-r--r--lib/psych/visitors/to_ruby.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/psych/visitors/to_ruby.rb b/lib/psych/visitors/to_ruby.rb
index 27b7778..8848c16 100644
--- a/lib/psych/visitors/to_ruby.rb
+++ b/lib/psych/visitors/to_ruby.rb
@@ -3,7 +3,13 @@ module Psych
###
# This class walks a YAML AST, converting each node to ruby
class ToRuby < Psych::Visitors::Visitor
+ def initialize
+ super
+ @st = {}
+ end
+
visitor_for(Nodes::Scalar) do |o|
+ @st[o.anchor] = o.value if o.anchor
o.value
end
@@ -22,6 +28,10 @@ module Psych
visitor_for(Nodes::Stream) do |o|
o.children.map { |c| c.accept self }
end
+
+ visitor_for(Nodes::Alias) do |o|
+ @st[o.anchor]
+ end
end
end
end