summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2009-09-30 09:53:54 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2009-09-30 09:53:54 -0700
commit1ecabe15cca7df942f9b3a8684145c5b8e3f0dda (patch)
treec7cf90d0b02ae0c78debf20892d548d42fd217eb /lib
parent1e1aadba8331c4f0ee607671e491b0eafc270531 (diff)
downloadpsych-1ecabe15cca7df942f9b3a8684145c5b8e3f0dda.zip
symbol round trip
Diffstat (limited to 'lib')
-rw-r--r--lib/psych/visitors/to_ruby.rb1
-rw-r--r--lib/psych/visitors/yast_builder.rb6
2 files changed, 6 insertions, 1 deletions
diff --git a/lib/psych/visitors/to_ruby.rb b/lib/psych/visitors/to_ruby.rb
index ee603ff..e585a01 100644
--- a/lib/psych/visitors/to_ruby.rb
+++ b/lib/psych/visitors/to_ruby.rb
@@ -15,6 +15,7 @@ module Psych
unless o.quoted
return nil if o.value =~ /^(null|~)$/i or o.value.empty?
+ return o.value.sub(/^:/,'').to_sym if o.value =~ /^:/
end
o.value
diff --git a/lib/psych/visitors/yast_builder.rb b/lib/psych/visitors/yast_builder.rb
index 52eae59..c3bd55d 100644
--- a/lib/psych/visitors/yast_builder.rb
+++ b/lib/psych/visitors/yast_builder.rb
@@ -21,7 +21,7 @@ module Psych
end
def visit_String o
- quote = !!(o =~ /^(null|~)$/i or o.empty?)
+ quote = !!(o =~ /^(null|~)$/i or o =~ /^:/ or o.empty?)
scalar = Nodes::Scalar.new(o, nil, nil, !quote, quote)
@stack.last.children << scalar
@@ -52,6 +52,10 @@ module Psych
append Nodes::Scalar.new('', nil, 'tag:yaml.org,2002:null', false)
end
+ def visit_Symbol o
+ append Nodes::Scalar.new ":#{o}"
+ end
+
private
def append o
@stack.last.children << o