summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2010-04-16 20:29:28 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2010-04-16 20:29:28 -0700
commite0e3ea15ea29271645f15e700dba96fab0d3628f (patch)
tree8330d2a7b4bb64bdcd7b45d0e686d119cc51df04 /lib
parentce61f13ac8ad2852b7b2543e6e130d9e0ae34d8a (diff)
downloadpsych-e0e3ea15ea29271645f15e700dba96fab0d3628f.zip
binary strings should be dumped with literal formatting
Diffstat (limited to 'lib')
-rw-r--r--lib/psych/visitors/yaml_tree.rb7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/psych/visitors/yaml_tree.rb b/lib/psych/visitors/yaml_tree.rb
index c70f248..5e773c9 100644
--- a/lib/psych/visitors/yaml_tree.rb
+++ b/lib/psych/visitors/yaml_tree.rb
@@ -171,10 +171,13 @@ module Psych
def visit_String o
plain = false
quote = false
+ style = Nodes::Scalar::ANY
if o.index("\x00") || o.count("^ -~\t\r\n").fdiv(o.length) > 0.3
str = [o].pack('m').chomp
- tag = '!binary'
+ tag = '!binary' # FIXME: change to below when syck is removed
+ #tag = 'tag:yaml.org,2002:binary'
+ style = Nodes::Scalar::LITERAL
else
str = o
tag = nil
@@ -184,7 +187,7 @@ module Psych
ivars = find_ivars o
- scalar = create_scalar str, nil, tag, plain, quote
+ scalar = create_scalar str, nil, tag, plain, quote, style
if ivars.empty?
append scalar