mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
This commit is contained in:
parent
186e575827
commit
6cfcb9d936
4 changed files with 31 additions and 2 deletions
|
@ -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.
|
||||
|
|
|
@ -8,6 +8,7 @@ require 'psych/omap'
|
|||
require 'psych/set'
|
||||
require 'psych/coder'
|
||||
require 'psych/core_ext'
|
||||
require 'psych/deprecated'
|
||||
|
||||
###
|
||||
# = Overview
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue