From d21bd1c06dbd04b89cdf4d50ce85fede95a7bcc9 Mon Sep 17 00:00:00 2001 From: why Date: Wed, 18 Jun 2003 01:06:00 +0000 Subject: * ext/syck/rubyext.c (rb_syck_load_handler): merge key implemented. * ext/syck/rubyext.c (transfer_find_i): removed use of String#=~ in favor of Regexp#match. * lib/yaml.rb: YAML::try_implicit returns. * lib/yaml/rubytypes.rb: Regexps added for type matching. * lib/yaml/emitter.rb: fix String + nil error. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3955 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/yaml.rb | 7 +++++++ lib/yaml/emitter.rb | 2 +- lib/yaml/rubytypes.rb | 10 +++++----- 3 files changed, 13 insertions(+), 6 deletions(-) (limited to 'lib') diff --git a/lib/yaml.rb b/lib/yaml.rb index 4bafa7c5d6..39e176541e 100644 --- a/lib/yaml.rb +++ b/lib/yaml.rb @@ -118,6 +118,13 @@ module YAML @@loader.transfer( type_id, obj ) end + # + # Apply any implicit a node may qualify for + # + def YAML.try_implicit( obj ) + YAML.transfer( YAML.detect_implicit( obj ), obj ) + end + # # Method to extract colon-seperated type and class, returning # the type and the constant of the class diff --git a/lib/yaml/emitter.rb b/lib/yaml/emitter.rb index 66c7a6e813..0255cc7d02 100644 --- a/lib/yaml/emitter.rb +++ b/lib/yaml/emitter.rb @@ -286,7 +286,7 @@ module YAML @buffer.push( "" ) #p [ self.id, @level, :END ] if @level < 0 - header + @buffer.to_s[@headless..-1] + header + @buffer.to_s[@headless..-1].to_s end end end diff --git a/lib/yaml/rubytypes.rb b/lib/yaml/rubytypes.rb index 2597c86a54..09aab98895 100644 --- a/lib/yaml/rubytypes.rb +++ b/lib/yaml/rubytypes.rb @@ -30,7 +30,7 @@ class Object end end -YAML.add_ruby_type( 'object' ) { |type, val| +YAML.add_ruby_type( /^object/ ) { |type, val| type, obj_class = YAML.read_type_class( type, Object ) YAML.object_maker( obj_class, val ) } @@ -86,7 +86,7 @@ hash_proc = Proc.new { |type, val| val } YAML.add_builtin_type( 'map', &hash_proc ) -YAML.add_ruby_type( 'hash', &hash_proc ) +YAML.add_ruby_type( /^hash/, &hash_proc ) module YAML @@ -166,7 +166,7 @@ class Struct end end -YAML.add_ruby_type( 'struct' ) { |type, val| +YAML.add_ruby_type( /^struct/ ) { |type, val| if Hash === val struct_type = nil @@ -238,7 +238,7 @@ array_proc = Proc.new { |type, val| end } YAML.add_builtin_type( 'seq', &array_proc ) -YAML.add_ruby_type( 'array', &array_proc ) +YAML.add_ruby_type( /^array/, &array_proc ) # # Exception#to_yaml @@ -262,7 +262,7 @@ class Exception end end -YAML.add_ruby_type( 'exception' ) { |type, val| +YAML.add_ruby_type( /^exception/ ) { |type, val| type, obj_class = YAML.read_type_class( type, Exception ) o = YAML.object_maker( obj_class, { 'mesg' => val.delete( 'message' ) }, true ) val.each_pair { |k,v| -- cgit v1.2.3