mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/yaml.rb (YAML::YAML): adjust Marshal version.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5227 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
43920ad28c
commit
d4e661b4ad
3 changed files with 13 additions and 8 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
Sat Dec 20 11:40:10 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* lib/yaml.rb (YAML::YAML): adjust Marshal version.
|
||||||
|
|
||||||
Sat Dec 20 02:41:02 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
|
Sat Dec 20 02:41:02 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
|
||||||
|
|
||||||
* lib/webrick/cgi.rb: add file. (yet another CGI library)
|
* lib/webrick/cgi.rb: add file. (yet another CGI library)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# vim:sw=4:ts=4
|
# -*- mode: ruby; ruby-indent-level: 4; tab-width: 4 -*- vim: sw=4 ts=4
|
||||||
# $Id$
|
# $Id$
|
||||||
#
|
#
|
||||||
# YAML.rb
|
# YAML.rb
|
||||||
|
@ -152,15 +152,15 @@ module YAML
|
||||||
def YAML.object_maker( obj_class, val, is_attr = false )
|
def YAML.object_maker( obj_class, val, is_attr = false )
|
||||||
if Hash === val
|
if Hash === val
|
||||||
name = obj_class.name
|
name = obj_class.name
|
||||||
ostr = sprintf( "\004\006o:%c%s\000", name.length + 5, name )
|
ostr = sprintf( "%c%co:%c%s\000", Marshal::MAJOR_VERSION, Marshal::MINOR_VERSION,
|
||||||
|
name.length + 5, name )
|
||||||
if is_attr
|
if is_attr
|
||||||
ostr[ -1, 1 ] = Marshal.dump( val ).sub( /^[^{]+\{/, '' )
|
ostr[ -1, 1 ] = Marshal.dump( val ).sub( /^[^{]+\{/, '' )
|
||||||
p ostr
|
|
||||||
end
|
end
|
||||||
o = ::Marshal.load( ostr )
|
o = ::Marshal.load( ostr )
|
||||||
unless is_attr
|
unless is_attr
|
||||||
val.each_pair { |k,v|
|
val.each_pair { |k,v|
|
||||||
o.instance_eval "@#{k} = v"
|
o.instance_variable_set("@#{k}", v)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
o
|
o
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
# -*- mode: ruby; ruby-indent-level: 4; tab-width: 4 -*- vim: sw=4 ts=4
|
||||||
require 'date'
|
require 'date'
|
||||||
#
|
#
|
||||||
# Type conversions
|
# Type conversions
|
||||||
|
@ -23,7 +24,7 @@ class Object
|
||||||
YAML::quick_emit( self.object_id, opts ) { |out|
|
YAML::quick_emit( self.object_id, opts ) { |out|
|
||||||
out.map( self.to_yaml_type ) { |map|
|
out.map( self.to_yaml_type ) { |map|
|
||||||
to_yaml_properties.each { |m|
|
to_yaml_properties.each { |m|
|
||||||
map.add( m[1..-1], instance_eval( m ) )
|
map.add( m[1..-1], instance_variable_get( m ) )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -253,7 +254,7 @@ class Exception
|
||||||
out.map( self.to_yaml_type ) { |map|
|
out.map( self.to_yaml_type ) { |map|
|
||||||
map.add( 'message', self.message )
|
map.add( 'message', self.message )
|
||||||
to_yaml_properties.each { |m|
|
to_yaml_properties.each { |m|
|
||||||
map.add( m[1..-1], instance_eval( m ) )
|
map.add( m[1..-1], instance_variable_get( m ) )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -264,7 +265,7 @@ YAML.add_ruby_type( /^exception/ ) { |type, val|
|
||||||
type, obj_class = YAML.read_type_class( type, Exception )
|
type, obj_class = YAML.read_type_class( type, Exception )
|
||||||
o = YAML.object_maker( obj_class, { 'mesg' => val.delete( 'message' ) }, true )
|
o = YAML.object_maker( obj_class, { 'mesg' => val.delete( 'message' ) }, true )
|
||||||
val.each_pair { |k,v|
|
val.each_pair { |k,v|
|
||||||
o.instance_eval "@#{k} = v"
|
o.instance_variable_set("@#{k}", v)
|
||||||
}
|
}
|
||||||
o
|
o
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue