From: Mauricio Fernandez Date: 2006-11-01T07:09:02+09:00 Subject: Re: Puzzling over why ri can open the std ruby/ri .yaml files, but raw yaml can't On Wed, Nov 01, 2006 at 06:05:12AM +0900, Eric Promislow wrote: > About to yaml <> > I get this error: > c:/ruby/lib/ruby/1.8/yaml.rb:133:in `transfer': invalid subclass > (TypeError) > from c:/ruby/lib/ruby/1.8/yaml.rb:133:in `load' > from get_yaml_info.rb:19:in `get_class_info' > from get_yaml_info.rb:19:in `get_class_info' > from get_yaml_info.rb:25 > > ruby 1.8.4 (2006-04-14) [i386-mswin32] > > It's the same code, and I don't see ri setting any options in the YAML > namespace telling it to process types like "!ruby/struct:SM::Flow::P" > differently, although I gather this is the problem. > > Any advice? $ cat ri-problem.rb require 'yaml' require 'pp' class RiFinder def initialize(sysdir) @sysdir = sysdir end def get_class_info(clsName, info) clsFile = "#{@sysdir}/#{clsName}/cdesc-#{clsName}.yaml" puts "About to yaml <<#{clsFile}>>" clsInfo = File.open(clsFile) { |io| YAML.load(io) } pp clsInfo end end rifinder = RiFinder.new("/usr/share/ri/1.8/system/") rifinder.get_class_info("Abbrev", nil) $ ruby ri-problem.rb About to yaml <> /home/batsman/usr//lib/ruby/1.8/yaml.rb:133:in `transfer': invalid subclass (TypeError) from /home/batsman/usr//lib/ruby/1.8/yaml.rb:133:in `node_import' from /home/batsman/usr//lib/ruby/1.8/yaml.rb:133:in `load' from /home/batsman/usr//lib/ruby/1.8/yaml.rb:133:in `load' from ri-problem.rb:12:in `get_class_info' from ri-problem.rb:12:in `open' from ri-problem.rb:12:in `get_class_info' from ri-problem.rb:18 $ echo 'require "rdoc/ri/ri_reader"' | cat - ri-problem.rb > ri-no-problem.rb $ ruby ri-no-problem.rb About to yaml <> #, #, #, #, #], @constants=[], @full_name="Abbrev", @includes=[], @instance_methods=[#], @name="Abbrev", @superclass=nil> -- Mauricio Fernandez - http://eigenclass.org - singular Ruby