From: nobu.nokada@... Date: 2005-09-21T07:31:07+09:00 Subject: Forward: [ruby-dev:27237] Re: yaml warnig in verbose mode Hi, It is reported YAML emits a lot of warnings in VERBOSE mode. Though I'm not sure why PrivateType and DomainType are separated into syck/rubyext.c and yaml/types.rb, this patch supresses the warnings. And I strongly recommend to always add file names and line numbers to eval. cvs diff: Diffing lib/yaml Index: lib/yaml/basenode.rb =================================================================== RCS file: /cvs/ruby/src/ruby/lib/yaml/basenode.rb,v retrieving revision 1.2.2.2 diff -U2 -p -w -r1.2.2.2 basenode.rb --- lib/yaml/basenode.rb 20 Sep 2005 06:46:45 -0000 1.2.2.2 +++ lib/yaml/basenode.rb 20 Sep 2005 15:04:17 -0000 @@ -149,5 +149,5 @@ module YAML case pred when /^\.=/ - pred = $' + pred = $' # ' match_nodes.reject! { |n| n.last.value != pred @@ -188,5 +188,5 @@ module YAML v[1] if v elsif Array === @value - @value.[]( *k ) + @value.[]( *key ) end end Index: lib/yaml/tag.rb =================================================================== RCS file: /cvs/ruby/src/ruby/lib/yaml/tag.rb,v retrieving revision 1.1.2.1 diff -U2 -p -w -r1.1.2.1 tag.rb --- lib/yaml/tag.rb 13 Sep 2005 03:58:33 -0000 1.1.2.1 +++ lib/yaml/tag.rb 20 Sep 2005 15:12:16 -0000 @@ -56,6 +56,7 @@ class Module # :nodoc: all # taguris. def yaml_as( tag, sc = true ) - class_eval <<-"end;" - attr_accessor :taguri + unless method_defined?(:taguri) + class_eval <<-"end;", __FILE__, __LINE__+1 + attr_writer :taguri def taguri if respond_to? :to_yaml_type @@ -72,4 +73,5 @@ class Module # :nodoc: all def self.yaml_tag_subclasses?; #{ sc ? 'true' : 'false' }; end end; + end YAML::tag_class tag, self end Index: lib/yaml/types.rb =================================================================== RCS file: /cvs/ruby/src/ruby/lib/yaml/types.rb,v retrieving revision 1.4.2.1 diff -U2 -p -w -r1.4.2.1 types.rb --- lib/yaml/types.rb 13 Sep 2005 03:58:33 -0000 1.4.2.1 +++ lib/yaml/types.rb 20 Sep 2005 15:26:25 -0000 @@ -10,7 +10,7 @@ module YAML class PrivateType def self.tag_subclasses?; false; end - attr_accessor :type_id, :value - def initialize( type, val ) - @type_id = type; @value = val + old_init = instance_method(:initialize) + define_method(:initialize) do |*args| + old_init.call(*args) @value.taguri = "x-private:#{ @type_id }" end @@ -26,6 +26,7 @@ module YAML def self.tag_subclasses?; false; end attr_accessor :domain, :type_id, :value - def initialize( domain, type, val ) - @domain = domain; @type_id = type; @value = val + old_init = instance_method(:initialize) + define_method(:initialize) do |*args| + old_init.call(*args) @value.taguri = "tag:#{ @domain }:#{ @type_id }" end -- Nobu Nakada