* 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
@ -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>
|
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.
|
* 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/set'
|
||||||
require 'psych/coder'
|
require 'psych/coder'
|
||||||
require 'psych/core_ext'
|
require 'psych/core_ext'
|
||||||
|
require 'psych/deprecated'
|
||||||
|
|
||||||
###
|
###
|
||||||
# = Overview
|
# = Overview
|
||||||
|
@ -219,10 +219,16 @@ module Psych
|
|||||||
end
|
end
|
||||||
|
|
||||||
def init_with o, h, node
|
def init_with o, h, node
|
||||||
|
c = Psych::Coder.new(node.tag)
|
||||||
|
c.map = h
|
||||||
|
|
||||||
if o.respond_to?(:init_with)
|
if o.respond_to?(:init_with)
|
||||||
c = Psych::Coder.new(node.tag)
|
|
||||||
c.map = h
|
|
||||||
o.init_with c
|
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
|
else
|
||||||
h.each { |k,v| o.instance_variable_set(:"@#{k}", v) }
|
h.each { |k,v| o.instance_variable_set(:"@#{k}", v) }
|
||||||
end
|
end
|
||||||
|
@ -36,6 +36,19 @@ module Psych
|
|||||||
return append Nodes::Alias.new target.object_id.to_s
|
return append Nodes::Alias.new target.object_id.to_s
|
||||||
end
|
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)
|
if target.respond_to?(:encode_with)
|
||||||
dump_coder target
|
dump_coder target
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user