aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog9
-rw-r--r--ext/psych/lib/psych.rb1
-rw-r--r--ext/psych/lib/psych/visitors/to_ruby.rb10
-rw-r--r--ext/psych/lib/psych/visitors/yaml_tree.rb13
4 files changed, 31 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 44b80d7f22..77b3b79cd8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+Sat Apr 10 05:27:26 2010 Aaron Patterson <aaron@tenderlovemaking.com>
+
+ * ext/psych/lib/psych/deprecated.rb: implementing Psych.quick_emit and
+ adding deprecation warnings.
+ * ext/psych/lib/psych/visitors/to_ruby.rb: supporting deprecated
+ yaml_initialize api.
+ * ext/psych/lib/psych/visitors/yaml_tree.rb: supporting deprecated
+ to_yaml api.
+
Sat Apr 10 01:08:53 2010 Aaron Patterson <aaron@tenderlovemaking.com>
* ext/psych/parser.c: parse raises a TypeError when nil is passed in.
diff --git a/ext/psych/lib/psych.rb b/ext/psych/lib/psych.rb
index 9b4b215b67..42cd8877be 100644
--- a/ext/psych/lib/psych.rb
+++ b/ext/psych/lib/psych.rb
@@ -8,6 +8,7 @@ require 'psych/omap'
require 'psych/set'
require 'psych/coder'
require 'psych/core_ext'
+require 'psych/deprecated'
###
# = Overview
diff --git a/ext/psych/lib/psych/visitors/to_ruby.rb b/ext/psych/lib/psych/visitors/to_ruby.rb
index 2790cdeb3d..56c970002c 100644
--- a/ext/psych/lib/psych/visitors/to_ruby.rb
+++ b/ext/psych/lib/psych/visitors/to_ruby.rb
@@ -219,10 +219,16 @@ module Psych
end
def init_with o, h, node
+ c = Psych::Coder.new(node.tag)
+ c.map = h
+
if o.respond_to?(:init_with)
- c = Psych::Coder.new(node.tag)
- c.map = h
o.init_with c
+ elsif o.respond_to?(:yaml_initialize)
+ if $VERBOSE
+ "Implementing #{o.class}#yaml_initialize is deprecated, please implement \"init_with(coder)\""
+ end
+ o.yaml_initialize c.tag, c.map
else
h.each { |k,v| o.instance_variable_set(:"@#{k}", v) }
end
diff --git a/ext/psych/lib/psych/visitors/yaml_tree.rb b/ext/psych/lib/psych/visitors/yaml_tree.rb
index e1e89a0d41..3cbb695bce 100644
--- a/ext/psych/lib/psych/visitors/yaml_tree.rb
+++ b/ext/psych/lib/psych/visitors/yaml_tree.rb
@@ -36,6 +36,19 @@ module Psych
return append Nodes::Alias.new target.object_id.to_s
end
+ if target.respond_to?(:to_yaml)
+ loc = target.method(:to_yaml).source_location.first
+ if loc !~ /(syck\/rubytypes.rb|psych\/core_ext.rb)/
+ unless target.respond_to?(:encode_with)
+ if $VERBOSE
+ warn "implementing to_yaml is deprecated, please implement \"encode_with\""
+ end
+
+ target.to_yaml(:nodump => true)
+ end
+ end
+ end
+
if target.respond_to?(:encode_with)
dump_coder target
else