Joel VanderWerf wrote:
> Joel VanderWerf wrote:
> 
>> [#9518] YAML: Derived String and binary data. [verified]
> 
> Here's a quick fix (also posted on the bug page):
> 
> --- rubytypes.rb.bck    2007-11-03 15:53:56.000000000 -0700
> +++ rubytypes.rb        2007-11-03 15:53:56.000000000 -0700
> @@ -163,7 +163,7 @@
>         def to_yaml( opts = {} )
>                 YAML::quick_emit( is_complex_yaml? ? object_id : nil, 
> opts ) do |out|
>              if is_binary_data?
> -                out.scalar( "tag:yaml.org,2002:binary", 
> [self].pack("m"), :literal )
> +                out.scalar( taguri.sub(/:str:/, ":binary:"), 
> [self].pack("m"), :literal )
>              elsif to_yaml_properties.empty?
>                  out.scalar( taguri, self, self =~ /^:/ ? :quote2 : 
> to_yaml_style )
>              else
> 
> Btw, there is also a bug with binary strings that have instance
> variables, but one at a time...

Sorry, this is the corrected patch.

--- rubytypes.rb.bck    2007-11-03 16:22:38.000000000 -0700
+++ rubytypes.rb        2007-11-03 16:22:38.000000000 -0700
@@ -146,7 +146,7 @@
          ( self.count( "^ -~", "^\r\n" ) / self.size > 0.3 || self.count( "\x00" ) > 0 ) unless empty?
      end
      def String.yaml_new( klass, tag, val )
-        val = val.unpack("m")[0] if tag == "tag:yaml.org,2002:binary"
+        val = val.unpack("m")[0] if /\Atag:yaml.org,2002:binary/ =~ tag
          val = { 'str' => val } if String === val
          if Hash === val
              s = klass.allocate
@@ -163,7 +163,7 @@
         def to_yaml( opts = {} )
                 YAML::quick_emit( is_complex_yaml? ? object_id : nil, opts ) do |out|
              if is_binary_data?
-                out.scalar( "tag:yaml.org,2002:binary", [self].pack("m"), :literal )
+                out.scalar( taguri.sub(/:str/, ":binary"), [self].pack("m"), :literal )
              elsif to_yaml_properties.empty?
                  out.scalar( taguri, self, self =~ /^:/ ? :quote2 : to_yaml_style )
              else

-- 
       vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407