diff options
author | tenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-04-09 20:33:21 +0000 |
---|---|---|
committer | tenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-04-09 20:33:21 +0000 |
commit | 6cfcb9d936af87b8ebfad23541e13af2cf6c95ef (patch) | |
tree | 60f137d313219a548bb6e5a211d547fa3837263d /ext | |
parent | 186e5758278f40e2415b5b1c7a4251900e9fe3b4 (diff) | |
download | ruby-6cfcb9d936af87b8ebfad23541e13af2cf6c95ef.tar.gz |
* 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.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27280 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r-- | ext/psych/lib/psych.rb | 1 | ||||
-rw-r--r-- | ext/psych/lib/psych/visitors/to_ruby.rb | 10 | ||||
-rw-r--r-- | ext/psych/lib/psych/visitors/yaml_tree.rb | 13 |
3 files changed, 22 insertions, 2 deletions
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 |